How to turn a regex to non-greedy

881 Views Asked by At

How to match any character up to the first occurrence of a pattern in a PCRE regex?

The following regex where I'm trying to turn on the non-greedy mode by adding a question mark after the +:

.+?(?=non)

applied to "Proin non urna non diam feugiat semper" matches "Proin non urna " instead of the desired output: "Proin ".

Thanks.

0

There are 0 best solutions below