JavaVerbalExpressions
JavaVerbalExpressions copied to clipboard
How do you express [0-9.,]
I can do add("[0-9.,]")
but it defies the purpose of the library.
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]|[\\,\\.])