Need regex to match 1 or more of exactly n-digit numbers -
i need regex match series of 1 or more n-digit numbers, separated comma, ie:
abc12345def returns 12345
abc12345,23456def returns 12345,23456
so far got this: \d{5}(,\d{5})*
problem matches in cases these:
123456 returns 12345, need not match if number longer 5. need numbers of 5 digits, , if number shorter or longer it's no-match
thanks
which language using regexes? want put non-digit markers around \d{5}
's; here perl syntax (with negative look-ahead/look-behind fix lukasz):
(?<![\d,])\d{5}(,\d{5})*(?![\d,])
Comments
Post a Comment