草庐IT

all_except

全部标签

php - 在 preg_match_all() 中需要一些关于正则表达式的帮助

所以我需要从字符串中提取票号“Ticket#999999”。我该如何使用正则表达式来执行此操作。如果我在Ticket#9999中有多个号码,我当前的正则表达式可以正常工作。但是如果我只有Ticket#9,它就不起作用了,请帮忙。当前正则表达式。preg_match_all('/(Ticket#[0-9])\w\d+/i',$data,$matches);谢谢。 最佳答案 在您的模式中,[0-9]匹配1个数字,\w匹配另一个数字,\d+匹配1+个数字,因此#后需要3位数字。使用preg_match_all('/Ticket#([0-9

PHP preg_match_all 正则表达式从 css 获取像素值( "px")

我正在寻找与PHP的preg_match_all()函数一起使用的正则表达式,它将为我提供CSS文件中的所有px值。例如,如果使用下面的css,那么预期结果将是一个数组:array("11px","0.45px","11.0005px","1.1px","888.888px")$pattern字符串是我目前所拥有的——但是它似乎没有用。我尝试使用的逻辑是:小数点前最多4位,小数点符号可选,小数点后可选,最多4位,后面跟“px”。$pattern="/([0-9]{1,4}\.*[0-9]{1,4}*px)/";$css='.some_class{font-size:11px;margi

php - 如何使用 preg_match_all 从字符串中检索三个参数?

我试图从文本中获取所有出现的代码片段和3个参数。我使用正则表达式和preg_match_allPHP函数来执行此操作。如果我在文本中只出现一次该片段,则效果很好。如果有两个或更多,我会得到一个奇怪的结果。我不是很擅长正则表达式,所以我很难理解我错过了什么。函数publicfunctiongetGallerySnippetOccurrences($text){$ptn='/{#+gallery+(src|width|height)=\[(.*)\]+(src|width|height)=\[(.*)\]+(src|width|height)=\[(.*)\]+#}/';if(preg_m

php - 有异常(exception)的 htmlentities

我有一些可能的标签,例如"","","".我想用htmlentities(htmlspecialchars)处理的其余字符X&Y结果应该是<>X&Y<<falsetag>最好的方法是什么。 最佳答案 您可以在文本上运行htmlentities,然后使用正则表达式替换允许的标签例子...$str='X&Y';$allowed_tags=array('tag','text','main');$escaped_str=htmlentities($str);$replace_what=array_map

PHP preg_match_all 在长字符串上失败

这是我的代码:$long=str_repeat('averylongstringtext',100);//trychanging100to5000$str=ashortstringtext$longSTR;preg_match_all('@([^]+)@sU',$str,$matched);print_r($matched);它完全按预期工作。但是,在你将100次重复更改为5000次之后,运行print_r($matched);而且您只会得到短字符串出现的结果。我的问题是如何使preg_match或preg_match_all处理大字符串文本(大至1MB或更大)?

php - SOAP 错误 fatal error : Uncaught SoapFault exception: [HTTP] Could not connect to host

我在使用PHPSoapClient发送SOAP请求时遇到此错误:Fatalerror:UncaughtSoapFaultexception:[HTTP]Couldnotconnecttohostin/var/www/phpwebservice/soap-client.php:6Stacktrace:#0[internalfunction]:SoapClient->__doRequest('__call('getCatalogEntry',Array)#2/var/www/phpwebservice/soap-client.php(6):SoapClient->getCatalogEnt

php - preg_match_all - 在字符串中查找完整 url 的正则表达式

我花了4个多小时试图找到我的php代码的正则表达式模式,但运气不佳。我有一个带有html代码的字符串。它有很多url格式,例如:example.comhttp://example.comhttp://www.example.comhttp://example.com/some.phphttp://example.com/some.php?var1=1http://example.com/some.php?var1=1&var2=2etc.我有以下部分工作的php代码:preg_match_all('/\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)[

php - <b> fatal error </b> : Uncaught exception 'Exception' with message 'Failed to connect to api.twitter.com port 443: Connection timed out'

我正在开发一个Codeigniter项目,在该项目中我使用twitterapi库来获取twitter数据。在我更改服务器之前它工作得很好,但是在更改服务器之后它产生了以下错误。我不知道问题所在。Fatalerror:Uncaughtexception'Exception'withmessage'Failedtoconnecttoapi.twitter.comport443:Connectiontimedout'in/my/project/path/myProject/application/ws/libraries/TwitterAPIExchange.php:297Stacktrac

php - 获取重音 preg_match_all 语法 PHP

我有这个preg_match_all来获取主题标签:preg_match_all('/(^|[^a-z0-9_])#([a-z0-9_]+)/ui',$text,$matchedHashtags);它工作得很好,但如果发现一些强调就会停止:#hash//works#hash_hash//works#hash_não//getjust$hash_n我需要改变什么? 最佳答案 您可以使用Unicodecategory信件。\p{L}匹配来自所有Unicodescripts的字母(≅语言)。正则表达式:/(?regex101Demo另一种

php - Laravel 验证 : required_with_all condition always passing

根据laravelvalidationdocumentation:required_with_all:foo,bar,...Thefieldundervalidationmustbepresentonlyifalloftheotherspecifiedfieldsarepresent.这是我的测试:Route::get('/test/{param}',function($param){$screenRules=array('foo'=>'string','param'=>'required_with_all:foo',);$validator=Validator::make(array