草庐IT

Match_parent

全部标签

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

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 - parent 是否可以从静态方法内部使用 child 的常量或静态变量?

下面是我正在尝试做的一个例子。parent无法访问child的任何变量。不管我使用什么技术(静态或常量),我只需要像这样的某种功能。classParentClass{publicstaticfunctionstaticFunc(){//bothofthesewillthrowa(static|const)notdefinederrorechoself::$myStatic;echoself::MY_CONSTANT;}}classChildClassextendsParentClass{constMY_CONSTANT=1;publicstatic$myStatic=2;}ChildC

PHP 继承 : child class overriding parent variable/property for use in constructor

我有一个(抽象的)父类应该在构造期间提供功能。子类可以覆盖构造函数中使用的属性:classParentextendsMiddlewareTest{//abstractchannelpropertiesprotected$title=NULL;protected$type=NULL;protected$resolution=NULL;function__construct(){parent::__construct();$this->uuid=$this->createChannel($this->title,$this->type,$this->resolution);}}classC

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

来自 Array with Multine 的 PHP 正则表达式 preg_match 不匹配所有 block

想知道是否有人可以帮助我使用以下正则表达式,我无法匹配blockmultineCF.{CoordonneesAbonne}:在PHP的preg_match函数中使用时。奇怪的是,当我在线执行正则表达式时,尽管该block在另一个组中,它似乎仍然有效regex101example这是代码:sourcecode'CF.{Temps}:1',2=>'CF.{Etat}:return',3=>'CF.{Code}:2',4=>'CF.{Values}:plaque',5=>'',6=>'CF.{Coordonnees}:LAPERSONNE',7=>'',8=>'10000LAVILLE',9

php - preg_match_all( ) 在不同的服务器上表现不同

下面的代码在我的PC上的XAMPP上运行完美,但在我新买的VPS上不起作用。它使我的代码崩溃。preg_match_all("/$regex/siU",$string,$matches,PREG_SET_ORDER);这应该只是从HTML中获取链接和标题。以前,今天也出现过类似的正则表达式问题。代码在本地服务器上运行良好,但在vps上创建“连接已重置”错误。该问题是由一些注释的html(其中包含php代码)引起的,使用以下代码将其删除以优化输出,但即使连接重置的问题已解决,HTML在浏览器源代码中仍然有注释。$string=preg_replace('//','',$string);那

PHP 面向对象 : Get all declared classes which are have extended another parent class

我需要获取所有扩展了另一个父类的声明类。例如……classParentClass{}classChildOneextendsParentClass{}classChildTwoextendsParentClass{}classChildThree{}我需要一个输出这个的数组:array('ChildOne','ChildTwo')我是PHPOOP的新手,但基于一些谷歌搜索,我想到了这个解决方案。$classes=array();foreach(get_declared_classes()as$class){if(is_subclass_of($class,'ParentClass'))