JavaVerbalExpressions icon indicating copy to clipboard operation
JavaVerbalExpressions copied to clipboard

How do you express [0-9.,]

Open jacool opened this issue 5 years ago • 1 comments

I can do add("[0-9.,]") but it defies the purpose of the library.

jacool avatar Aug 08 '18 07:08 jacool

It is not exactly the same, but you could do:

regex().oneOf(
      regex().range("0","9").build().toString(), 
      regex().anyOf(",.").build().toString()
).build()

Which would be equivalent to

(?:(?:[0-9])|(?:[\\,\\.]))

Simplifying for clarity:

([0-9]|[\\,\\.])

onilton avatar Feb 09 '21 03:02 onilton