匹配中文标点符号:
String str='[u3002uff1buff0cuff1au201cu201duff08uff09u3001uff1fu300au300b]'
该表达式可以识别出: 。 ; , : “ ”( ) 、 ? 《 》这些标点符号。
匹配中文汉字
String str='[u4e00-u9fa5]';
该表达式可以识别出任何汉字。
例子:
[php]
$origin_text=’京港台:2014-10-13 18:20 来源:人民网’
$pattern="/x{FF1A}[x{3000}x{feff}x20]?([x{3002}x{ff1b}x{ff0c}x{ff1a}x{201c}x{201d}x{ff08}x{ff09}x{3001}x{ff1f}x{300a}x{300b}x{4e00}-x{9fa5}a-zA-Z0-9]*)/u";
$origin=”;
if(preg_match_all($pattern,$origin_text,$matches)){
//print_r($matches);
if(!empty($matches[2][1])){
$origin=$matches[2][1];
}else{
$origin=$matches[1][1];
}
}
[/php]
赞过:
赞 正在加载……
相关