A little preg_match issue
Hi,
A quick question - i have a string containing text like this:
\\u003cspan class=\\\"someClass\\\">Some text\\u003c\\\/span>
How do i get that "Some text" value into an array? I tried
preg_match_all("/\\\\u003cspan class=\\\\\\\"someClass\\\\\\\">(.*?)\\\\u003c\\\\\\/span>/",$str,$res);
Returns nothing. I think there's something wrong with the regex pattern. Maybe anyone can correct me?
Thanks
Buppy
Junior Poster in Training
86 posts since Nov 2010
Reputation Points: 12
Solved Threads: 2
My tool shows a match:
preg_match_all('%\\\\\\\\u003cspan class=\\\\\\\\\\\\"someClass\\\\\\\\\\\\">(.*?)\\\\\\\\u003c\\\\\\\\\\\\/span>%s', $subject)
The backslash needs to be escaped in the regex (which you did), but also in the string (which you did not).
pritaeas
Posting Expert
5,483 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875