草庐IT

sub_match

全部标签

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 - Sublime Text 3 : how to see the sub-array content in the Xdebug context 中的 Xdebug

当我用Xdebug设置一个断点时,我可以看到当前环境变量的内容。其中一些变量是一个数组,里面有另一个数组。我不知道如何查看该子数组的内容:这可能吗?怎么办? 最佳答案 将以下内容添加到Xdebug插件的用户配置文件中(Preferences>PackageSettings>Xdebug>Settings-User):{"max_depth":2}那是一个子数组。如果你想要一个子子数组,只需键入:"max_depth":3... 关于php-SublimeText3:howtoseethe

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 数组 : join each sub-array together (Probability)

我只是想找出更好的方法来做到这一点:$array=array(array('a','b','c'),array('e','f','g'),array('h','i','j','k','l'));目标是打印这样的东西:aehaeiaejaekaelafhafiafjafkaflaghagiagjagkagl然后对b和c做同样的事情。目前,我正在使用这段代码:foreach($array[0]as$val1){foreach($array[1]as$val2){foreach($array[2]as$val3){echo"$val1$val2$val3\n";}echo"--------\

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 查找多次出现

在PHP中使用preg_match查找同一字符串多次出现的正则表达式的正确语法是什么?例如,查找以下字符串是否在以下段落中出现两次:$string="/brownfoxjumped[0-9]/";$paragraph="Thebrownfoxjumped1timeoverthefence.Thegreenfoxdidnot.Thenthebrownfoxjumped2timesoverthefence"if(preg_match($string,$paragraph)){echo"matchfound";}else{echo"matchNOTfound";}

php - 如何精确匹配 PHP 的 preg_match 中的 3 位数字?

这个问题在这里已经有了答案:`preg_match`theWholeStringinPHP(3个答案)关闭3年前。假设您具有以下值:12312344567121我正在尝试纠正preg_match,它只会为“123”返回true,因此只有3位数字才匹配。这是我的,但它也匹配1234和4567。我可能还有一些东西。preg_match('/[0-9]{3}/',$number);