如何捕获Total Payout: ->Capture<-
之后的任何内容忽略所有数字
Confirmation code:
Payout:
€66 x 7 Nights: €461
Airbnb Service Fee: -€17
Total Payout: €444
生活例子:
使用'K
或向后看
'bTotal Payout:'s*'K.+
Total Payout:'s+'K'D+
此处可以使用'K
'K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
.
看演示。https://regex101.com/r/gM6pO2/3
您可以使用?<=
查看此模式(?<=Total Payout:)'s+(.*'d+)
然后捕获组
查看演示https://regex101.com/r/gM6pO2/4
确认码:
输入Payout:
€66 x 7 Nights: €461
Airbnb Service Fee: -€17
Total Payout: €444
€444
您可以使用/.*(€'d+)/
,例如:
<?php
$string = <<< EOF
Confirmation code:
Payout:
€66 x 7 Nights: €461
Airbnb Service Fee: -€17
Total Payout: €444
EOF;
preg_match_all('/.*(€'d+)/si', $string, $matches, PREG_PATTERN_ORDER);
$totalPayout = $matches[1][0];
echo $totalPayout;
//€444
演示:
http://ideone.com/gmS1uf