简体   繁体   中英

Problems with PHP, preg_replace & regular expressions

I'm trying to run this php command:

preg_replace($regexp, $replace, $text, $maxsingle);

Where the vars are:

$regexp = '/(?!(?:[^<\\[]+[>\\]]|[^>\\]]+<\\/a>))\\b(שלום)\\b/imsU';
$replace = '<a title="$1" href="http://stackoverflow.com">$1</a>';
$text is a long post
$maxsingle = 3;

When the text I'm trying to match (in the above case "שלום") is in english everything works. However, when the text is Hebrew, it doesn't matches anything...

Any ideas how to make Hebrew work with preg_replace ?

Thanks.

尝试使用/ u(utf-8)标志

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM