PHP在指定的段落之后进行下一个工作

时间:2018-12-14 02:38:34

标签: php regex string

我有一个像这样的字符串:

Staff Juan Dela Cruz < Junior System Developer > total login hours is 12.12 and total adjusted hours is 12. Total worked hours adjustments due to approved worked hours on 2017-05-08. Adjusted Hours is 12 +GST

我想在短语12之后得到Adjusted Hours。我怎么做?我只是一直想在Adjusted Hours

之后说一句话

1 个答案:

答案 0 :(得分:1)

尝试此正则表达式:

Adjusted Hours is (\d+)

regex101 demo

完整的PHP代码:

$str = 'Staff Juan Dela Cruz < Junior System Developer > total login hours is 12.12 and total adjusted hours is 12. Total worked hours adjustments due to approved worked hours on 2017-05-08. Adjusted Hours is 12 +GST ';

preg_match('/Adjusted Hours is (\d+)/m', $str, $matches);

var_dump($matches[1]); // => 12

3v41.org demo