-6


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

dani77
  • 169
  • 1
  • 5
  • 21
  • 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
  • 227,407
  • 48
  • 383
  • 507
0

Read this. And use this:

"^[05]$"

Yevhen Kuzmovych
  • 7,193
  • 5
  • 23
  • 40