草庐IT

Preg_Match

全部标签

php - 文件获取内容(): Peer certificate did not match

我使用的是PHP5.5,但我被迫更新它,现在我使用的是PHP5.6.19。现在,当我尝试与外部API通信时,我收到警告:Warning:file_get_contents():PeercertificateCN=*.domain.com'didnotmatchexpectedCN=api.domain.com'在以前的PHP版本中没有出现。$encryptedEncodedData//thisisjsonencoded//array,thenencryptedbymcryptwithrijndael-128andfinallybin2hex.$context=stream_contex

php - preg_match_all 中的 UTF-8 字符 (PHP)

这个问题在这里已经有了答案:preg_matchandUTF-8inPHP(8个答案)关闭9个月前。我有preg_match_all('/[aäeëioöuáéíóú]/u',$in,$out,PREG_OFFSET_CAPTURE);如果$in='hëllo'$out是:array(1){[0]=>array(2){[0]=>array(2){[0]=>string(2)"ë"[1]=>int(1)}[1]=>array(2){[0]=>string(1)"o"[1]=>int(5)}}}o的位置应该是4。我在网上看到了这个问题(ë算作2)。有解决办法吗?我见过mb_substr和类

php - 警告 : preg_replace(): No ending delimiter '/' found

这个问题在这里已经有了答案:WhatDelimitertouseforpreg_replaceinPHP(replaceworkingoutsideofPHPbutnotinside)(3个答案)关闭7年前。警告:preg_replace():Noendingdelimiter'/'foundinC:\wamp\www\upload\upload_demo.phponline77我使用preg_replace()将斜杠替换为反斜杠。但它显示了上述警告。这是代码..functiondel_file($file){$delete=@unlink($file);clearstatcache(

php - 有效模式的 PHP 中的 "preg_match(): Compilation failed: unmatched parentheses"

想知道是否有人可以阐明为什么在PHP的preg_match函数中使用以下正则表达式会失败:-这会导致错误消息“preg_match():编译失败:括号不匹配”,尽管该模式似乎是有效的。我用在线测试了它PHPRegularExpressiontester和Linux工具Kiki。似乎PHP正在转义左括号而不是反斜杠。我通过使用str_replace将反斜杠换成正斜杠来解决这个问题。这适用于我的情况,但很高兴知道为什么这个正则表达式失败。 最佳答案 要对文字反斜杠进行编码,您需要将其转义两次:一次用于字符串,一次用于正则表达式引擎:pr

php - 从字符串中获取电子邮件 - 正则表达式语法 + preg_match_all

这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭9年前。我正在尝试从字符串中获取电子邮件:$string="blablapickachu@domain.comMIME-Version:balbasur@domain.comblablabla";$matches=array();$pattern='\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b';preg_match_all

php - preg_match : nothing to repeat/no match

我正在使用这个:if(!preg_match('/^+[0-9]$/','+1234567'))并且得到:Warning:preg_match()[function.preg-match]:Compilationfailed:nothingtorepeatatoffset1有什么想法吗?更新:现在使用这个:if(!preg_match('/^\+[0-9]$/','+1234567'))我找不到匹配项。有什么想法吗? 最佳答案 +是一个特殊字符,表示前一个字符的1个或多个,不转义它就是将它应用于插入符号。用\转义它,它将匹配文字加号

鸿蒙app启动远程平板报错解决方法The type of the target device does not match the deviceType configured in the confi

鸿蒙app启动远程平板报错解决方法ThetypeofthetargetdevicedoesnotmatchthedeviceTypeconfiguredintheconfig.jsonfileoftheselectedmodulehttps://www.cnblogs.com/txwtech/p/17892200.html ThetypeofthetargetdevicedoesnotmatchthedeviceTypeconfiguredintheconfig.jsonfileoftheselectedmodule.在entry->src->main->config.json,添加table

php - 仅匹配来自相同语言的字符集(如 facebook 名称)?

preg_match(???,'firstnamelastname')//true;preg_match(???,'서프누워')//true;preg_match(???,'서프lastname')//false;preg_match(???,'#$@#$$#')//false;目前我使用:'/^([一-龠0-9\s]+|[ぁ-ゔ0-9\s]+|[ก-๙0-9\s]+|[ァ-ヴー0-9\s]+|[a-zA-Z0-9\s]+|[々〆〤0-9\s]+)$/u'但它只适用于某些语言。 最佳答案 您需要一个表达式,它只匹配来自相同unico

PHP preg_match 圣经经文格式

我正在努力构建一个正则表达式来解析这种字符串(圣经经文):'John14:16–17,25–26''John14:16–17''John14:16''John14''John'所以基本模式是:书籍[[Chapter][:Verse]]章节和诗歌是可选的。 最佳答案 我认为这可以满足您的需求:\w+\s?(\d{1,2})?(:\d{1,2})?([-–]\d{1,2})?(,\s\d{1,2}[-–]\d{1,2})?假设:数字总是以1位或2位数字为一组破折号将匹配以下任一-和–下面是带有注释的正则表达式:"\w#Matchasin

php - 如何验证一个字符串只包含小写字母?

我正在尝试验证我的字符串是否与模式匹配。也就是说,完整的字符串可以写成那个模式。但是,如果任何子字符串与该模式匹配,preg_match将返回true。(例如preg_match("#[a-z]*#,"333k")返回1,这是我不想的。在这个例子中,我宁愿验证整个字符串只包含小的拉丁字母。) 最佳答案 您分别使用start和end标记,^和$来指示开始和结束正则表达式模式中的字符串。这样你就可以让表达式只匹配整个字符串,而不是任何一种子字符串。在您的情况下,它看起来像这样:preg_match("#^[a-z]*$#","333k"