Is there a compelling reason to use quantifiers in Perl regular expressions instead of just repeatin
- by Morinar
I was performing a code review for a colleague and he had a regular expression that looked like this:
if ($value =~ /^\d\d\d\d$/) {
#do stuff
}
I told him he should change it to:
if ($value =~ /^\d{4}$/) {
#do stuff
}
To which he replied that he preferred the first for readability (I find the second more readable, but that's a religious debate I'll save for another day).
My question: is there an actual benefit to one over the other?