-3

I would like to know why preg_match('/(?<=\s)[^,]+(?=\s)/',$data,$matches); matches "List Processes 8989" in the string "20180513 List Processes 8989". The regex I am using should not match numeric characters. What is wrong?

1 Answers1

2

The [^,] basically means any character except ,. If you want to exclude numeric characters as well, you can replace it with [^,0-9], or better [^,\d], so your regex would look like this:

(?<=\s)[^,\d]+(?=\s)

Try it online.

I'm assuming the input string in your question is only part of the actual input string you're using because the regex you provided won't match the numbers at the end unless they're followed by a whitespace.


References: