草庐IT

match_index

全部标签

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 - preg_match中的 `e`修饰符是什么意思?

我正在检查PHP代码是否存在可疑代码。我找到了preg_match('/^'.preg_quote($var1,'/').'/ie',$var2)但php不会发出任何警告,例如The/emodifierisdeprecated,usepreg_replace_callbackinsteadin或Unknownmodifier'e'in。测试:http://3v4l.org/6i8lne(PREG_REPLACE_EVAL)修饰符对preg_match有特殊意义还是被忽略? 最佳答案 嗯,在preg_match()中,修饰符e不会做任

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 - 为什么当我使用 simplexml_load_file() 时 preg_match() 结果在 PHP 中显示为 0?

我的php有一些问题,这是我的代码test.xml类似:Test655Tsungphp代码:asXML());$pattern="/结果显示为“0”,表示未找到,所以我更改$pattern值$pattern="document";结果显示“1”(表示找到)我调试了很多时间...也许编码UTF-8,ASCIIprobram或"/错了吗?我的目的是想解析这个字符串然后得到'..'有人可以告诉我我的错误在哪里吗??谢谢:)) 最佳答案 您正在使用解析器,只需解析它,不需要正则表达式。$xml='Test655Tsung';$xml=new

php - Apache 使用 https 全部重定向到 index.php

我已经阅读了很多关于这个主题的答案,但没有人提到如何结合:将所有流量重定向到index.php+将所有http重定向到httpS以下内容非常适合将所有内容重定向到index.php:RewriteEngineOnRewriteBase/RewriteCond%{REQUEST_FILENAME}!-fRewriteCond%{REQUEST_FILENAME}!-dRewriteCond$1!^(index\.php|public|css|js|robots\.txt)RewriteRule^(.*)index.php/params=$1[L,QSA]在我这样做之前,我能够使用这个强制

php - CodeIgniter 从 url 中删除 index.php

我知道这个问题已经被问过很多次了。但是,我仍然无法摆脱index.php网址。它阻止我直接访问我的Controller。我目前正在使用CodeIgniter2.2.2。以下是我的.htaccess文件:RewriteEngineOnRewriteCond%{REQUEST_FILENAME}!-fRewriteCond%{REQUEST_FILENAME}!-dRewriteRule^(.*)$index.php/$1[L]应用/配置://Findthebelowcode$config['uri_protocol']="AUTO"//Replaceitas$config['uri_pr

PHP preg_match 不适用于换行

这个问题在这里已经有了答案:PHPRegex:Howtomatch\rand\nwithoutusing[\r\n]?(7个答案)关闭去年。我有这个漂亮的preg_match正则表达式:if(preg_match("%^[A-Za-z0-9ążśźęćńółĄŻŚŹĘĆŃÓŁ\.\,\-\?\!\(\)\"\\/\t\/\n]{2,50}$%",stripslashes(trim($_POST['x']))){...}这应该允许可以在帖子中使用的所有字符以及帖子的最终文本内容。问题是,尽管\n它的功能仍然不适用于我帖子中的新行,因此语法为foobar不会工作。有谁知道为什么该功能无法正

php - 为什么PhpStorm会报 "Argument type does not match"错误?

我正在使用PhpStorm10.0.2开发一个PHP7项目。每当我为函数参数声明PHPDoc@param时,该参数具有标量类型的类型提示(string、int、...)我收到这个警告:Argumenttypedoesnotmatch这是PhpStorm提示的一些示例代码:classHostConfig{/***@varstring*/private$hostname;/***@varstring*/private$domainname;/***CreatesanewinstanceofhteHostConfigmodel.**@paramstring$hostnameAhostname

php - 正则表达式 preg_match 未按预期工作

所以我从数据库中获取链接,这些链接看起来像这样:www.website.com/games/randomcode1/RANDOM-URL-TITLE-NEEDED.htmlwww.website.com/blabla/randomcode2/RANDOM-URL-TITLE-NEEDED2.htmwww.website.com/whatever/randomcode2/RANDOM-URL-TITLE-NEEDED3.html在我的foreach循环中,Urls表示为$row['links'];我想做的是只采用RANDOM-URL-TITLE-NEED。这意味着我需要url中从最后一个

php - Codeigniter 链接在 url 中没有 index.php 的情况下无法工作

我开发了一个使用codeigniter的Web应用程序,我的Web应用程序的所有URL结构如下:/Admin/Promotions这种类型的链接在我的Localhost上运行良好,但在我的托管服务器上不起作用(我正在使用Godaddy托管)但是一些在URL中有index.php的链接也在本地主机和服务器上工作,这个链接之王的结构是index.php/Admin/Pramotions我应该怎么做才能使没有index.php的URL正常工作??我的HTACCESS:RewriteEngineOnRewriteCond%{REQUEST_FILENAME}!-fRewriteCond%{RE