Example: https://regex101.com/r/n4x91E/1
INPUT STRING :
"I think we have to point certain things out to this man, and after that point some other things out to him as well"
MY REGULAR EXPRESSION :
(point).*(out)
RETURNING WRONG RESULT :
"I think we have to point certain things out to this man, and after that point some other things out
to him as well"
EXPECTING RESULT :
"I think we have to point certain things out
to this man, and after that point some other things out to him as well"
How to change my regular expression to get the first groups occurrence ?
You can use a lazy quantifier for your regular expression like in this version:
https://regex101.com/r/n4x91E/2
(point).*?(out)
In the Java documentation this quantifier is called reluctant, but I think lazy is more commonly used...
You can try this:
(point).*?(out)
If you only want the first occurrence then don't use global flag... it only match the first occurrence . see the following link . Otherwise you can put the global flag 'g'
Explanation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With