in reply to Number of digits at the end of the string
If there are always at least five characters in the string then
if an acceptable string could be exactly four digits then/\D\d{4}$/
/ (?: # either ^ # start of string | # or \D # a non digit ) \d{4} # exactly four digits $ # end of string /x
Update: /(?<!\d)\d{4}$/ covers all cases, I tend to forget about look behind because I have to use fairly ancient perls as well as the more modern varients and so code for the lowest denominator.
|
|---|