-edit- NOTE the ? at the end of .{2,}?
I found out you can write
.{2,}?
Isnt that exactly the same as below?
.{2}
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.
No, they are different.
^.{2,}?$matches strings whose length is at least 2 (as seen on rubular.com):By contrast,
^.{2}$only matches strings whose length is exactly 2 (as seen on rubular.com).It’s correct that being reluctant,
.{2,}?will first attempt to match only two characters. But for the overall pattern to match, it can take more. This is not the case with.{2}, which can only match exactly 2 characters.References
Related questions
.*?and.*for regex