【发布时间】:2011-10-11 19:30:11
【问题描述】:
我一直在从编码中搜索单词边界:
<?php
header('Content-Type: text/plain; charset="ISO-8859-7"');//Changing the charset attribute
$i=0;
for($i=0;$i<=255;$i++){
$char=chr($i);
if(preg_match('/^\w$/',$char,$m)){
echo "[".ord($m[0])."]";}
}
?>
我不知道是不是错了。 但无论指定什么字符集,总是给我某些职位。 似乎总是,无论采用何种编码,'\w' 都与来自 ISO-8859-1 的字的字节相匹配。
【问题讨论】:
-
@hakre 你对 \b 感到困惑,因为 \w 真的匹配一个单词字符。 regular-expressions.info/reference.html