Aim:
Capture everything up until a character sequence & if those character sequences don't exist, capture entire text.
Character sequences:
| table &
| stats
Ex 1:
search foo bar | table _time Action Direction
returns search foo bar
Ex 2:
search foo bar hello hi ciao 1234
returns search foo bar hello hi ciao 1234
Ex 3:
search foo bar
bar foo
| table _time Action Direction
returns
search foo bar
bar foo
Current solution which doesn't satisfy Ex 2:
(?<var>(?s).+?(?=\Q| table\E|\Q| stats\E))
You can use https://regex101.com/ for testing.
Any help would be very appreciated! Thank you.
bar foo
| table _time Action Direction returns: search foo bar
bar foo
– Johno Cown Sep 02 '21 at 21:23