How can i capture anything after the Total Payout: ->Capture<-
Ignore all numbers
Confirmation code:
Payout:
€66 x 7 Nights: €461
Airbnb Service Fee: -€17
Total Payout: €444
Use \K
or lookbehind.
\bTotal Payout:\s*\K.+
Total Payout:\s+\K\D+
You can use \K
here.
\K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
.
See demo.
You can make use of a look behind ?<=
See this pattern (?<=Total Payout:)\s+(.*\d+)
Then capture the group.
Check out the demo https://regex101.com/r/gM6pO2/4
Confirmation code:
Input
Payout:
€66 x 7 Nights: €461
Airbnb Service Fee: -€17
Total Payout: €444
Output
€444
You can use /.*(€\d+)/
, i.e.:
<?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
DEMO: