草庐IT

string-matching

全部标签

php - preg_match 用于某些部分的评论

我想找到评论的某些部分。以下是一些例子/**@todonameanother-nametaskID*//*@todonameanother-nametaskID*/目前我正在使用以下正则表达式'/\*[[:space:]]*(?=@todo(.*))/i'这将返回以下内容:*@todonameanother-nametaskIDor*@todonameanother-nametaskID*/我怎样才能只得到@todo和名称,而不是任何星号?期望的输出@todonameanother-nametaskID@todonameanother-nametaskID

php - 使用 preg_match_all 匹配模式并排除子字符串

我需要找到位于START和END之间的所有字符串,从匹配的字符串中排除PADDING子字符串。我发现的最好方法是$r="stuffSTARTthisPADDINGisENDstuffstuffSTARTwhatPADDINGIwantPADDINGtoPADDINGfindENDstuff";preg_match_all('/START(.*?)END/',str_replace('PADDING','',$r),$m);print(join($m[1]));>thisiswhatIwanttofind我想用尽可能小的代码来做到这一点:有一个更短的只有preg_match_all没有s

javascript - Ajax 调用在 CodeIgniter 中返回 int 而不是 string

这是我的模型。getitems会根据location从数据库中获取itemnameclassItemsale_dbextendsCI_ModelpublicfunctiongetItems($userid,$loc){$sql="SELECTDISTINCTNamefromitransfilewhere";if(is_numeric($loc))$sql.="location_id=".$loc;else$sql.="location_idIN(SELECTlocation_idFROMclient_locationswhereclient_id=".$userid.")";$quer

php - haxe (php) https 调用 : stream_socket_client() Peer certificate CN did not match expected CN

我正在使用haxe的Http类(编译为php)通过https将request()发送到AWS。这是一个使用haxe-aws库(https://github.com/Blank101/haxe-aws)的最小示例:variamconf=newIAMConfig('newbucket.s3-eu-central-1.amazonaws.com',accessKey,secretKey,'eu-central-1','s3');varsig4=newSig4Http('https://newbucket.s3-eu-central-1.amazonaws.com/',iamconf);sig

php - php 中的 preg_match

我想使用preg_match()这样给定字符串中就不应该有特殊字符,例如``@#$%^&/'`。例如:编码:输出有效:输出无效(以空格开头的字符串)项目管理:输出有效(两个词之间的空格有效)'Design23':输出有效23Designing:输出无效123:输出无效我尝试了但无法得出有效答案。 最佳答案 像这样的正则表达式有帮助吗?^[a-zA-Z0-9]\w*$意思是:^=这个模式必须从字符串的开头开始[a-zA-Z0-9]=此字符可以是任何字母(a-z和A-Z)或数字(0-9,另见\d)\w=单词字符。这包括字母、数字和空格(

php - 具有错误字符容忍度的最长公共(public)子串

我在这里找到了一个脚本,它在寻找最低公共(public)子串时效果很好。但是,我需要它来容忍一些不正确/缺失的字符。我希望能够输入所需的相似度百分比,或者指定允许的缺失/错误字符数。例如,我要查找这个字符串:黄色大校车这个字符串的内部:那天下午他们乘坐了大黄校车这是我目前使用的代码:functionlongest_common_substring($words){$words=array_map('strtolower',array_map('trim',$words));$sort_by_strlen=create_function('$a,$b','if(strlen($a)==s

php - Twig:打印变量名为 String 的变量的值

我有一个名为e.g.的变量var1其值为value1作为字符串。如何打印变量var1的值,其中var1是作为字符串获取的?让{{setcontainer='var1'}}container变量的值是动态的。根据container的值,我需要打印它的值;在这种情况下,我需要打印“value1”。我正在寻找这样的东西{{attribute(this,container)}}/*this没有在Twig中定义*/ 最佳答案 原来我错了。您可以使用包含所有传递给模板的变量的_context变量。试试{{dump(_context)}}Rele

php - Laravel 解析错误 : syntax error, unexpected T_CLASS, expecting T_STRING

我在今年8月开发了一个laravel应用程序,当时它运行良好。我现在正在尝试运行该应用程序,但它返回了这个错误:parseerror:syntaxerror,unexpectedT_CLASS,expectingT_STRINGorT_VARIABLEor'{'or'$'inD:\bkonme\artisanline31第31行是这样的:$kernel=$app->make(Illuminate\Contracts\Console\Kernel::class);我的PHP版本是5.6.14,我在windows平台上使用XAMPP。我有一些想法,因为laravel和PHP之间存在一些版本

php - preg_match_all html 标签,双引号或单引号中的标签除外

给定这个DOM$html=Bye","info":"Wewin"}'>TheAAnythinghere"}'>EOD;我正在尝试使用此表达式来preg_match_allhtml标签:$tags=array();if(preg_match_all('~]*>|~im',$html,$matchall,PREG_SET_ORDER)){foreach($matchallas$m){$tags[]=$m[0];}}print_r($tags);这个表达式的输出是:Array([0]=>[1]=>[2]=>[3]=>[4]=>[5]=>[6]=>[7]=>[8]=>[9]=>[10]=>[1

php - 正则表达式(php 中的 preg_match): last groups in the output array don't work correctly

使用这种模式:(howis\s)?(the\s)?(weather)\s?((on)\s)?(today|tomorrow|sunday|monday|tuesday|wednesday|thursday|friday|saturday|sunday|thisweek)?(\s(in)\s(.*)\s?(on)?\s?(today|tomorrow|sunday|monday|tuesday|wednesday|thursday|friday|saturday|sunday|thisweek)?)?这就是我要捕捉的东西输入:维也纳星期二的天气怎么样输出:array(100=>howis