regex - "eager" regexp matching -


I have to remove the string between two delimiters, i.e. "123XabcX321" I need "123321". For a simple matter, I am fine with the following:

  $ _ =  & gt;; S / X (. *) X //; Print;   

But if there is ambiguity in input like "123XabcXasdfjXasdX321", then it matches X before the previous X and I get "123321" but I need "123asdfj321" Is there a way to specify a "curious" match that matches the first valid delimiter and is not the last one?

This is usually called "unbound", do you put one? After Quantifier: s / x (. *?) X //;

Comments