Regex Problem in PHP
- by Chris
I'm attempting to utilize the following Regex pattern:
$regex = '/Name: [a-zA-Z ]*] [0-9]/';
When testing it in Rubular, it works fine, but when using PHP the expression never returns true, even when it should. Incidentally, if I remove the "[0-9]" part, it works fine. Is there some difference in PHP's regex syntax that I'm overlooking?
Edit:
I'm looking for the characters "Name:" then a name containing any number of letters or spaces, then a "]", then a space, then a single number. So
"Name: Chris] 5" would return true and
"Name: Chris] [lorem ipsum]" should return false.
I also tried escaping the second bracket "\[" but this did not fix the problem.