Daniel B. Daniel B. - 10 months ago 76
Java Question

Java - Regex only 0 or 5



Regular expression only accepts 0 or 5.

Is there a regex expression to evaluate that?

Thanks.

Answer Source

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.