I'm having a java regex problem.
how can I find pattern of 1 or more numbers followed by a single . in a string?
+: one or more ( 1+ ), e.g., [0-9]+ matches one or more digits such as '123' , '000' . *: zero or more ( 0+ ), e.g., [0-9]* matches zero or more digits. It accepts all those in [0-9]+ plus the empty string.
Method 1: Regex re. To get all occurrences of a pattern in a given string, you can use the regular expression method re. finditer(pattern, string) . The result is an iterable of match objects—you can retrieve the indices of the match using the match.
The plus sign + is a greedy quantifier, which means one or more times. For example, expression X+ matches one or more X characters. Therefore, the regular expression \s matches a single whitespace character, while \s+ will match one or more whitespace characters.
"^[\\d]+[\\.]$"
^ = start of string
[\\d] = any digit
+ = 1 or more ocurrences
\\. = escaped dot char
$ = end of string
(\\d)+\\.
\\d
represents any digit+
says one or more
Refer this http://www.vogella.com/articles/JavaRegularExpressions/article.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With