简体   繁体   English

使用preg_match匹配特殊字符

[英]match special character using preg_match

if i use this it woks just fine: 如果我使用它,就可以了:

$string = 'prueba Numero de Documento: 0206728108 Gracias';

preg_match('#Numero de Documento: (\w+)#', $string, $match);
echo $match[1];

OUTPUTS: 0206728108 输出: 0206728108

and this does not work: 这不起作用:

$string = 'prueba Número de Documento: 0206728108 Gracias';

preg_match('#Número de Documento: (\w+)#', $string, $match);
echo $match[1];

EMPTY OUTPUT 空输出

Use the u modifier for unicode: u修饰符用于unicode:

preg_match('#Número de Documento: (\w+)#u', $string, $match);
//                              here ___^

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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