We are trying to use regex_replace in tpl file:
{$item->order->order->notes_priv|regex_replace:"/.+?(?=MATCH)/":""}
But this leaves all strings after "MATCH" not the only first one after "MATCH".
We have this text and would like to input only one string after word MATCH:
foo bar foo bar MATCH 12 foo bar
foo bar foo bar MATCH 24,00 foo bar
How we can make input?
12
24,00
We tried many solutions but without success.
You can use
See the regex demo.
The main idea is to match the whole string, capture just a part and replace with a backreference to the captured group value.
Details:
.*- any zero or more chars other than line break chars as many as possibleMATCH- a literal string\s+- one or more whitespaces(\S+)- Group 1 ($1in the replacement pattern): any one or more non-whitespace chars.*- any zero or more chars other than line break chars as many as possible.