I have done extensive reading, but have trouble solving this scenario. I want to matching everything in between abc
and xyz
, in a non greedy way - without any extra abc
or xyz
in the matched string.
For example, if my input is abc abc xyz xyz
, i want to get abc xyz
as the output. If I use /abc.*?xyz/g
as the expression, it returns abc abc xyz
. xyz
is matched non greedily. How can I get abc
also matched non-greedily?
For the input like, abc pqr abc lmn xyz lmn xyz
, output should be abc lmn xyz