ICode9

精准搜索请尝试: 精确搜索
  • 我如何匹配字符串中的所有内容,直到第二次出现带有正则表达式的定界符?2019-12-10 05:38:45

    我试图通过查找第二个出现的句点然后一个空格来完善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

  • 正则表达式-PHP2019-11-23 07:32:08

    我正在使用以下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-如何解析m3u8并获取不同的bitttrate子m3u8网址?2019-11-21 19:45:35

    任何人都可以告诉我如何在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在标签之间找不到字符串?2019-11-21 11:33:38

    我在这里有下一个问题.我正在尝试使用preg_match / preg_match_all获取两个HTML注释标签之间的字符串,但是我得到的结果是带有很多记录的空数组. 这是我的代码: $pattern = "/\<!-- Start of NewsTicker --\>(.*)\<!-- End of NewsTicker --\>/"; preg_match_all($pattern, $descri

  • php-preg_match_all()不匹配所有可能的出现2019-11-19 07:29:10

    我有二进制模式“ 10000101001”,我想匹配在开始和结束1处具有0的字符串.因此,对于上面给出的示例,应该有3种可能的匹配100001、101、1001. 以下是我尝试的示例代码: function solution() { $length = 0; $decStr = "10000101001"; $pattern = "/[1][^1]0*[1]/"; p

  • php-正则表达式检查另一个字符串中是否存在一个字符串2019-11-08 09:40:36

    我正在尝试在/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

  • php-preg_match获取文本2019-10-31 02:30:22

    我有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获取文本

  • php-preg_match_all-正则表达式,用于查找字符串中的完整网址2019-10-29 20:28:42

    我花了超过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

  • php-preg_replace即使在第一次替换后也可以匹配字符串中的所有匹配项2019-10-27 19:33:40

    输出: $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中使用正则表达式找到完全匹配的内容?2019-10-25 11:30:37

    在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

  • php-通过HTML文本匹配产品价格2019-10-14 04:34:49

    我正在尝试对字符串进行简单的正则表达式以获取价格信息,但是我的preg_match_all根本没有找到应有的内容. 我正在寻找例如$**.**或£**.**,或者有时货币符号可能被编码为HTML实体,例如英镑和英镑或&#163; 使用preg_match_all查找html实体是否存在问题? 这是我正在尝试的: $price = p

  • php-查找字符串中的子字符串,其中子字符串封装在特定字符中2019-10-12 20:31:06

    我有以下格式的字符串: "The quick __grey__ fox jumps over the lazy __brown__ dog." 我想查找并替换双下划线之间的任何单词(有时是句子). 我目前在PHP中使用preg_match_all: $pattern = '/__(.*)__/'; 效果很好…直到在同一行上找到两组双下划线,例如上面的示例,在此我想匹配

  • PHP-如何循环,匹配和替换?2019-10-11 18:33:03

    我有多个带有相同花括号的字符串,如果计数为1,则希望将其替换为动态字符串,然后需要替换第一个匹配项;如果计数为2,则替换第二个匹配项,以此类推,直到条件满足为止. <?php include_once("con.php"); $db = new Da(); $con = $db->con(); $String = "{{ONE}} {{TWO}} {{THREE}} {

  • php – 如何使用preg_match_all()获取子组匹配的所有捕获?2019-09-19 01:29:01

    参见英文答案 > 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 – 正则表达式(preg_match)2019-09-02 19:32:52

    这是不工作的代码: <?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/

  • php – 正则表达式,用于提取没有空格的哈希标记2019-09-01 04:30:29

    我正在使用这个: $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

  • 为什么PHP preg_match_all与PCRE_UTF8在CLI和Apache / mod_php上给出不同的结果?2019-08-31 12:30:54

    通过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

  • Php Regex查找string是否为mysql select语句2019-08-30 15:39:03

    我正在尝试在执行它们之前验证查询,如果查询不是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*'[^']*

  • PHP Regex – 使用逗号分隔符拆分字符串,标记之间使用IGNORE逗号2019-08-30 10:37:57

    鉴于此字符串: $somethingawesome = '<[return date("Y-m-d", strtotime("yesterday"));]>,<[return "cool!";]>,TRUE,foo'; 我如何获得这样的数组: Array ( [0] => <[return date("Y-m-d", strtotime("yesterda

  • 如何使用php获取字符串中以’#’开头的单词?2019-08-24 00:29:24

    参见英文答案 > 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

  • php – 在换行符中使用preg_match_all2019-07-29 03:30:52

    我正在尝试使用preg_match_all从网站上获取特定部分的出现,我之前已成功完成此操作,但现在的区别在于这些部分跨越换行符……我已经理解了,我应该可以用一些修饰符来做到这一点…… 因此,相关网站上的部分结构如下: <div id="LICRabatGuideAftale"> <something in between>

  • php – 如何从字符串中获取特定值2019-07-17 09:29:27

    我在尝试从字符串中提取特定值但未获得正确输出时遇到问题. $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

  • php – 为什么preg_match_all()多次创建相同的答案?2019-07-16 17:31:02

    以下代码从推文中提取#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

  • php – 为什么preg_match_all返回两个匹配项?2019-07-13 22:28:16

    我试图识别一个字符串是否在使用preg_match_all的双引号之间有任何单词,但它是重复结果,并且第一个结果有两组双引号,其中被搜索的字符串只有一组. 这是我的代码: $str = 'Test start. "Test match this". Test end.'; $groups = array(); preg_match_all('/"([^"]+)"/', $str, $gr

  • php – preg_match用于评论的某些部分2019-07-09 11:39:23

    我想找到评论的某些部分.以下是一些例子 /* * @todo name another-name taskID */ /* @todo name another-name taskID */ 目前我使用以下正则表达式 '/\*[[:space:]]*(?=@todo(.*))/i' 这返回以下内容: * @todo name another-name taskID or * @todo name another-name tas

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有