Daniel B. Daniel B. - 2 months ago 12
Java Question

Java - Regex only 0 or 5

Regular expression only accepts 0 or 5.

Is there a regex expression to evaluate that?



You can use either "0|5" or "[05]". The first is an alternative, the second is a character class. They will behave identically. See the documentation for Pattern for more information on the building blocks for regular expressions.