954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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
Moderator
5,483 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: