我试图通过查找第二个出现的句点然后一个空格来完善preg_match_all: <?php $str = "East Winds 20 knots. Gusts to 25 knots. Waters a moderate chop. Slight chance of showers."; preg_match_all ('/(^)((.|\n)+?)(\.\s{2})/',$str, $matches); $dataarray=$matche
我正在使用以下PHP代码 <? $data = file_get_contents('http://www.kitco.com/texten/texten.html'); preg_match_all('/([A-Z]{3,5}\s+[0-9]{1,2},[0-9]{4}\s+([0-9.NA]{2,10}\s+){1,7})/si',$data,$result); $records = array(); foreac
任何人都可以告诉我如何在php中使用get_data方法获取主播放列表m3u8,从而获得不同的bitrate(resolution)子m3u8 url.有人可以告诉我如何做到这一点吗? $returned_content = get_data(''.$m3u8Url); /* gets the data from a URL */ function get_data($url) { $ch = curl_init(
我在这里有下一个问题.我正在尝试使用preg_match / preg_match_all获取两个HTML注释标签之间的字符串,但是我得到的结果是带有很多记录的空数组. 这是我的代码: $pattern = "/\<!-- Start of NewsTicker --\>(.*)\<!-- End of NewsTicker --\>/"; preg_match_all($pattern, $descri
我有二进制模式“ 10000101001”,我想匹配在开始和结束1处具有0的字符串.因此,对于上面给出的示例,应该有3种可能的匹配100001、101、1001. 以下是我尝试的示例代码: function solution() { $length = 0; $decStr = "10000101001"; $pattern = "/[1][^1]0*[1]/"; p
我正在尝试在/dir1/dir2/dir3/dir4/../dir7/dir8/dir9/target-.a-word1-word2-alpha2-alphanumberic1-alphanumberic2.md的字符串中查看/ target-的存在. $re = '/^(.*?)(\/target-)(.*?)(\.md)$/i'; $str = '/dir1/dir2/dir3/dir4/../dir7/dir8/dir9/target-.a-word1-word2
我有test.php,在test1.php上,我正在运行此php代码 <?php $Text=file_get_contents("http://inviatapenet.gethost.ro/sop/test.php"); preg_match_all('~fid="(.*?)"~si',$Text,$Match); $fid=$Match[1][1]; echo $fid; ?> 我想要做的是从test.php获取文本
我花了超过4个小时的时间来尝试找到一个php的正则表达式,但没有运气. 我有一个带有html代码的字符串. 它具有许多网址格式,例如: site*com http://site*com http://www*site*com http://site*com/some.php http://site*om/some.php?var1=1 http://site*com/some.php?var1=1&var2=2
输出: $san_field = 'sometext PROS sometext sometext1234 CALEND 2007 RIT'; $pattern = '/(\s|^|- |--)(?:CALEND|2007|CALEND 2007 RIT)(--| -|\s|$)/i'; echo preg_replace($pattern, ' ', $san_field) >> sometext PROS sometext
在PHP中使用正则表达式模式尝试与URL匹配时遇到一些问题. 我的正则表达式: / article /([[0-9A-Za-z -_]] / post /([0-9A-Za-z-_]) public function matches(Route $route){ $uri = filter_var(strip_tags($_SERVER['REQUEST_URI']), FILTER_SANITIZE_URL); if (preg_matc
我正在尝试对字符串进行简单的正则表达式以获取价格信息,但是我的preg_match_all根本没有找到应有的内容. 我正在寻找例如$**.**或£**.**,或者有时货币符号可能被编码为HTML实体,例如英镑和英镑或£ 使用preg_match_all查找html实体是否存在问题? 这是我正在尝试的: $price = p
我有以下格式的字符串: "The quick __grey__ fox jumps over the lazy __brown__ dog." 我想查找并替换双下划线之间的任何单词(有时是句子). 我目前在PHP中使用preg_match_all: $pattern = '/__(.*)__/'; 效果很好…直到在同一行上找到两组双下划线,例如上面的示例,在此我想匹配
我有多个带有相同花括号的字符串,如果计数为1,则希望将其替换为动态字符串,然后需要替换第一个匹配项;如果计数为2,则替换第二个匹配项,以此类推,直到条件满足为止. <?php include_once("con.php"); $db = new Da(); $con = $db->con(); $String = "{{ONE}} {{TWO}} {{THREE}} {
参见英文答案 > Get repeated matches with preg_match_all() 6个 更新/注意事项: I think what I’m probably looking for is to get the 07001 in PHP. 参考文献:PCRE regular expressions using name
这是不工作的代码: <?php $matchWith = " http://videosite.com/ID123 "; preg_match_all('/\S\/videosite\.com\/(\w+)\S/i', $matchWith, $matches); foreach($matches[1] as $value) { print '<a href="http://videosite.com/
我正在使用这个: $t = "#hashtag #goodhash_tag united states #l33t this"; $queryVariable = ""; if(preg_match_all('/(^|\s)(#\w+)/', $t, $arrHashTags) > 0){ array_filter($arrHashTags); array_unique($arrHashTags); $coun
通过CLI和Apache / mod_php运行时,以下代码会产生不同的结果: <pre> <?php error_reporting(E_ALL); ini_set('display_errors', '1'); echo setlocale(LC_ALL, 0)."\n"; // echo setlocale(LC_ALL, "en_GB.UTF-8")."\n"; $ter
我正在尝试在执行它们之前验证查询,如果查询不是mysql select语句,那么我必须向用户显示消息. 我从这个链接找到了以下正则表达式: Validate simple select query using Regular expression $reg="/^Select\s+(?:\w+\s*(?:(?=from\b)|,\s*))+from\s+\w+\s+where\s+\w+\s*=\s*'[^']*
鉴于此字符串: $somethingawesome = '<[return date("Y-m-d", strtotime("yesterday"));]>,<[return "cool!";]>,TRUE,foo'; 我如何获得这样的数组: Array ( [0] => <[return date("Y-m-d", strtotime("yesterda
参见英文答案 > Retrieve all hashtags from a tweet in a PHP function 5个 我有这句话 "My name's #jeff,what is thy name?" 现在我想从这句话中得到#jeff.我试过这段代码 for ($i=0; $i <=substr_c
我正在尝试使用preg_match_all从网站上获取特定部分的出现,我之前已成功完成此操作,但现在的区别在于这些部分跨越换行符……我已经理解了,我应该可以用一些修饰符来做到这一点…… 因此,相关网站上的部分结构如下: <div id="LICRabatGuideAftale"> <something in between>
我在尝试从字符串中提取特定值但未获得正确输出时遇到问题. $string = com.xyz.ghop.service.sprint.Sprint@1b0258c[id=257,rapidViewId=94,state=CLOSED,name=Alert Success 5,goal=,startDate=2016-08-16T20:20:46.730+05:30,endDate=2016-08-26T20:20:00.000+05:30,completeDa
以下代码从推文中提取#hashtags并将它们放在变量$matches中. $tweet = "this has a #hashtag a #badhash-tag and a #goodhash_tag"; preg_match_all("/(#\w+)/", $tweet, $matches); var_dump( $matches ); 有人可以向我解释为什么以下结果有2个相同的数组而不是1个? array(2
我试图识别一个字符串是否在使用preg_match_all的双引号之间有任何单词,但它是重复结果,并且第一个结果有两组双引号,其中被搜索的字符串只有一组. 这是我的代码: $str = 'Test start. "Test match this". Test end.'; $groups = array(); preg_match_all('/"([^"]+)"/', $str, $gr
我想找到评论的某些部分.以下是一些例子 /* * @todo name another-name taskID */ /* @todo name another-name taskID */ 目前我使用以下正则表达式 '/\*[[:space:]]*(?=@todo(.*))/i' 这返回以下内容: * @todo name another-name taskID or * @todo name another-name tas