Recently seen a piece of code:
"; ? >
On the internet to check a lot of information, but for the PHP regular expression pattern modifier u really some do not understand, solve ah ...
Reply to discussion (solution)
The u:unicode abbreviation, which indicates that the string to be matched is a string conforming to the Unicode encoding rules, such as a utf-8 encoded string
Under the U modifier, a kanji is treated as a character. \w has the original [_0-9a-za-z] extended to Chinese characters
\w is extended to Chinese characters by the original [_0-9a-za-z],
\w matches any number, letter, underline, what does it mean to extend to Chinese characters?
$s = ' Kanji abc ';p reg_match_all ('/\w/', $s, $r); No U-Modified print_r ($R);
Have
Array
(
[0] = = Array
(
[0] = a
[1] = b
[2] = C
)
)
$s = ' Kanji abc ';p reg_match_all ('/\w/u ', $s, $r); There are U-modified print_r ($R);
Have
Array
(
[0] = = Array
(
[0] = Han
[1] = Word
[2] = a
[3] = b
[4] = C
)
)
$s = ' Kanji abc ';p reg_match_all ('/\w/', $s, $r); No U-Modified print_r ($R);
Have
Array
(
[0] = = Array
(
[0] = a
[1] = b
[2] = C
)
)
$s = ' Kanji abc ';p reg_match_all ('/\w/u ', $s, $r); There are U-modified print_r ($R);
Have
Array
(
[0] = = Array
(
[0] = Han
[1] = Word
[2] = a
[3] = b
[4] = C
)
)
Moderators greatly write a suitable for beginners to learn the regular bar.
Is there a big difference between. NET Regular and PHP?
Http://deerchao.net/tutorials/regex/regex.htm
This person writes. NET easy to understand, ask moderator greatly similar to a ...
Thank the moderator, understand ...