问题描述
\\ $DigitalSignature have full name value passed
$SignatureMatch = '/' . strtolower( $NameFirst . ' ' . $NameLast ) . '$/';
if( true == preg_match( $SignatureMatch, strtolower( $DigitalSignature ) ) )
{
$boolIsValid = true;
}
我要使用此代码来使名字和姓氏与数字签名完全匹配.但这会在生产(实时)的错误日志中向我报告错误.
I am having this code for exact matching first name and last name match with digital signature. But this gives error reported me in error log on production(live).
preg_match(): Unknown modifier 'b'
我无法重现此错误.我首先如何得到这个错误.以及如何解决此错误以进行精确匹配.
I am unable to reproduce this error. How can I get this error firstly. And how to resolve this error for exact matching.
我已经看到许多关于SO的问题,但没有得到何时会出现此错误.以及我该如何解决.我见过的许多问题是-
I have seen many questions on SO but not getting when will get this error. And how do I resolve that. Some of questions out of many I have saw are -
- 警告:preg_match()[function.preg-match]:未知修饰符
- preg_match()语句中的未知修饰符
- 警告:preg_match()[function.preg-match]:未知修饰符
- 未知的修饰符"l"错误
- 未知修饰符'g'PHP regex错误
- ...中的未知修饰符"/"?是什么?
- preg_match()未知修饰符'['帮助
- 警告:preg_match()[function.preg-match ]:未知修饰符'v'
- PHP Preg_match匹配完全匹配的单词
- 使用preg_match时未知的修饰符'v'( )在正则表达式中表达
- preg_match(); -未知修饰符"+"
- preg_match错误未知修饰符'{'
- 使用preg_match(时,未知修饰符'(' )和REGEX表达式
- Warning: preg_match() [function.preg-match]: Unknown modifier
- Unknown modifier in preg_match() statement
- Warning: preg_match() [function.preg-match]: Unknown modifier
- Unknown modifier 'l' error
- Unknown modifier 'g' PHP regex error
- Unknown modifier '/' in ...? what is it?
- preg_match() Unknown modifier '[' help
- Warning: preg_match() [function.preg-match]: Unknown modifier 'v'
- PHP Preg_match match exact word
- Unknown modifier 'v' when using preg_match() expression in regex
- preg_match(); - Unknown modifier '+'
- preg_match error Unknown modifier '{'
- Unknown modifier '(' when using preg_match() with a REGEX expression
推荐答案
如果名字或姓氏包含/
,则您的正则表达式将类似于:
If the first name or last name contains a /
, your regex will look something like:
/john/doe$/
对于preg_match
,看起来正则表达式是/john/
,后跟的doe$/
是修饰符.这些当然是无效的修饰符.您需要使用 preg_quote
来对正则表达式自身中的正则表达式定界符(/
)进行转义.
To preg_match
, this looks like the regex is /john/
, with the trailing doe$/
being the modifiers. Those are of course invalid modifiers. You need to escape the regex delimiters (/
) inside the regex itself using preg_quote
.
这篇关于什么时候preg_match():未知的修饰符错误发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!