Stephane
Stephane

Reputation: 5078

extracting unicode string with preg_match_all()

I'm trying to extract string using the following code:

$item = 'id="firstname" l="Prénom" n="firstname" t="text" v=""';
preg_match_all('#(?:l|label|lbl)\s*=\s*"([\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}\x{00C6}\x{00C7}\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{00CC}\x{00CD}\x{00CE}\x{00CF}\x{00D0}\x{00D1}\x{00D2}\x{00D3}\x{00D4}\x{00D5}\x{00D6}\x{00D7}\x{00D8}\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{00DD}\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}\x{00E6}\x{00E7}\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{00EC}\x{00ED}\x{00EE}\x{00EF}\x{00F0}\x{00F1}\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{00FD}\x{00FF}\sa-zA-Z0-9_-]+)"#is', $item, $m);

It works fine when using a non-unicode string like "firstname" but returns an empty value when $item contains a string like "Prénom"

Any idea why ?

Upvotes: 0

Views: 713

Answers (1)

Botanick
Botanick

Reputation: 663

Simply add u to the list of modificators: isu.

Upvotes: 1

Related Questions