本文介绍了什么时候preg_match():未知的修饰符错误发生?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

\\    $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 -

  1. 警告:preg_match()[function.preg-match]:未知修饰符
  2. preg_match()语句中的未知修饰符
  3. 警告:preg_match()[function.preg-match]:未知修饰符
  4. 未知的修饰符"l"错误
  5. 未知修饰符'g'PHP regex错误
  6. ...中的未知修饰符"/"?是什么?
  7. preg_match()未知修饰符'['帮助
  8. 警告:preg_match()[function.preg-match ]:未知修饰符'v'
  9. PHP Preg_match匹配完全匹配的单词
  10. 使用preg_match时未知的修饰符'v'( )在正则表达式中表达
  11. preg_match(); -未知修饰符"+"
  12. preg_match错误未知修饰符'{'
  13. 使用preg_match(时,未知修饰符'(' )和REGEX表达式
  1. Warning: preg_match() [function.preg-match]: Unknown modifier
  2. Unknown modifier in preg_match() statement
  3. Warning: preg_match() [function.preg-match]: Unknown modifier
  4. Unknown modifier 'l' error
  5. Unknown modifier 'g' PHP regex error
  6. Unknown modifier '/' in ...? what is it?
  7. preg_match() Unknown modifier '[' help
  8. Warning: preg_match() [function.preg-match]: Unknown modifier 'v'
  9. PHP Preg_match match exact word
  10. Unknown modifier 'v' when using preg_match() expression in regex
  11. preg_match(); - Unknown modifier '+'
  12. preg_match error Unknown modifier '{'
  13. 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():未知的修饰符错误发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-23 23:57