how find last 6 digits of string using regex in java?
for instance, have string: 238428342938492834823
i want have string finds last 6 digits, no matter length of string is. have tried "/d{6}$"
no success.
any suggestions or new ideas?
you used wrong escape character. \d{6}
matches 6 digits, while /d
matches literal forward-slash followed 6 literal d
's.
the pattern should be:
\d{6}$
of course, in java, have escape \
, that:
string pattern = "\\d{6}$";
Comments
Post a Comment