dongmi1864 2012-06-20 09:16
浏览 52
已采纳

PHP - 在字符串中查找数字

I want to get 16 from this string :

request id is 16 (group id 1) for host localhost

And the Status message of JID No. 10 (which is in this case Kill time expired)

JID  Pri S  Owner Number       Pages Dials      Status
11   127 D   root 0xxxxxx     1:1   1:12         
16   116 F www-da 0xxxxxx     0:1  12:12         No carrier detected; too 
15   127 D   root 0xxxxxx     1:1   1:12         
10   127 F   root 0xxxxxx     0:0   0:12         Kill time expired
9    127 F   root 0xxxxxx     0:0   0:12         Job aborted by request
8    127 F   root 0xxxxxx     0:0   0:12         Job aborted by request

EDIT : I managed to solve the first problem. the answer is (\d+). I need a hint for the second search.

  • 写回答

1条回答 默认 最新

  • dongzhoutuo0883 2012-06-20 10:30
    关注

    For the second one, you could look for a line that starts with "10", then "something" and then 9 consecutive spaces. After the spaces is what you need to capture. The regex is ^10.+\s{9}(.*)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题