Please give an example where the difference between greedy and lazy versions of repeat-exactly-m-times
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As said in comments, Oniguruma regexp engine treats it differently, as an exception:
{m}?is not a non-greedy exact m (which is same as greedy exact m), but 0-or-m. All the other engines I tried did as other posters say: it makes no difference.The reason for the non-greedy exact m to exist: if it didn’t, it’s an exception. Exceptions are harder to remember, and harder to implement – it’s extra work, and in this case, as the semantics is equal, it doesn’t hurt anyone.
I love Oniguruma, and appreciate they might have wanted to change the unneeded bit into something more usable and efficient, but this looks like a bug waiting to happen. Fortunately, no-one sane writes non-greedy exact m…