has anyone any idea why do I get full match of ".abcd" using the regex below on the string I posted? I imagine this regex to only capture ".abc" as a full match.
^(\.)([a-z]+){3}$
String: .abcd
Best regards:)
has anyone any idea why do I get full match of ".abcd" using the regex below on the string I posted? I imagine this regex to only capture ".abc" as a full match.
^(\.)([a-z]+){3}$
String: .abcd
Best regards:)
The engine presumably works with your input as follows:
[a-z]+
=> abcd
=> first repetitionabcd => abc
=> 1st rep[a-z]+
=> d
=> 2nd repabc => ab
=> 1st repcd
=> 2nd repcd => c
=> 2nd repd
=> 3rd repIn general, "quantified quantifiers" are very dangerous, because they involve lots of backtracking, see e.g. http://www.rexegg.com/regex-explosive-quantifiers.html
You're currently saying start with a .
then have at least 3 letters then end.
People, or at least I, suck at reading regex but here is a cool webpage that turns it into a flow chart for you https://regexper.com/#%5E%28%5C.%29%28%5Ba-z%5D%2B%29%7B3%7D%24
^\.[a-z]{3}$
This is the regex you need dot followed by three small letters