regex - regular expression in java inside an if block -
this question has reply here:
reference - regex mean? 1 replyi can see below regular look in code ...
if (amount.matches("[-+]?[0-9]*\\.?[0-9]+")) homecoming true;
now query regular look represent amount should numeric , validation check
your regex works :
"[-+]?[0-9]*\\.?[0-9]+" [-+]? --> either `+` or `-` or nothing. followed [0-9]* --> number of digits (* implies greedy check). followed `\\.?` --> 0 or 1 `.` (matched literally. ). followed [0-9]+ --> 1 or more digits
demo here
java regex
No comments:
Post a Comment