Preg match with php PCRE error

Hey,

I need to preg match the string
“\r
\u003cstrong\u003e\r
(.*)u\003c”. I have tried making my own regex and ended up with

preg_match("/\\\\r\\\
 \\\\u003cstrong\\\\u003e\\\\r\\\
 (.*)u\\\\003c/iUs", $a, $b);

But I get the error

Compilation failed: PCRE does not support \\L, \\l, \\N, \\U, or \\u at offset 6

I have tried Googling it and playing about with it myself but to no avail. Any ideas anyone?

Thanks in advance

the pcre functions don’t support unicode, but there is no reason to use unicode in this case anyway - just replace those characters with the < and > signs. Also you are double escaping things that don’t need to be double escaped. try this:

preg_match("/\\r\
 <strong>\\r\
 (.*)</iUs", $a, $b);

try this instead

preg_match(“/\\r\
\\<u003cstrong>\\u003e\\r\
(.*)u\\003c/iUs”, $a, $b);

First reply gives me no error but also no data and the second reply gives me

Compilation failed: PCRE does not support \\L, \\l, \\N, \\U, or \\u at offset 20

I am going to try preg_replace the u003c and u003e out tomorrow though and see if I can match off that.

Actually I misunderstood - you need to triple escape, i.e.
\\\r\\\

Not
\\r\\

Etc

Hope that makes sense

looking at this again, I am really mucking up this thread :blush:. You actually need to quadruple escape, and escape all regex control characters:

preg_match("/\\\\\\\\r\\\\\\\
 \\\\\\\\u003cstrong\\\\\\\\u003e\\\\\\\\r\\\\\\\
 \\(\\.\\*\\)u\\\\\\\\003c/iUs", $str, $b)