dowb58485 2015-08-09 07:04
浏览 66
已采纳

来自数字序列的php preg_match提取以514开头的10位数字

from a sequence of numbers I want to extract 10 digits that begins by 514

Example 2134565323551412344558987

With preg_match or any other php code I want to extract the 5141234455

I Tried this code

preg_match_all("/^514/", $contentNumbersFromURL, $matches)

Bu I get

array(1) { [0] => array(0) {} }
  • 写回答

1条回答 默认 最新

  • dream890110 2015-08-09 07:05
    关注

    You need to remove start of the line anchor ^. ^ matches the line starting boundary. Since there isn't a number 514 exists at the start, your regex got failed.

    preg_match_all('/514\d{7}/', $contentNumbersFromURL, $matches)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决