-6


Regular expression only accepts 0 or 5.
Is there a regex expression to evaluate that?
Thanks.

dani77
  • 199
  • 2
  • 5
  • 26
  • You need to go actually learn regexes. Asking if a regex can do this is like asking whether Java can add numbers, or asking whether cars can move. – user2357112 Nov 24 '16 at 01:03
  • @user2357112 I don't want to learn regex, I only want to know that. Thanks for subtract me reputation. – dani77 Nov 24 '16 at 01:19

2 Answers2

2

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.

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
0

Read this. And use this:

"^[05]$"

Yevhen Kuzmovych
  • 10,940
  • 7
  • 28
  • 48