Daniel B. Daniel B. - 1 year ago 94
Java Question

Java - Regex only 0 or 5

Regular expression only accepts 0 or 5.

Is there a regex expression to evaluate that?


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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download