regex - Quantifier to print only three digit numbers in a Java regular expression -
what quantifier print 3 digit numbers in string in java regular expressions?
input : 232,60,121,600,1980 output : 232,121,600
instead output coming as:
output : 232,121,600,198
i using (\\d{3})
. quantifier should use in order print 3 digit numbers?
you need make use of \b
word boundary:
\b\d{3}\b
see demo
in java, use double slashes:
string pattern = "\\b\\d{3}\\b";
you not need use capturing group round whole regex, can access match via .group()
. see ideone demo
Comments
Post a Comment