2

I am trying to check my string having 123.12/23 with pattern \\d+(.\\d+)*\\/\\d+(.\\d+)* but it is not working, it is passing 123.12/23/24 also.

I need below scenarios to be covered :

Strings to be passed : 12/23 , 12.23/23 , 12/23.33

Strings to be failed : 12/13/14 , 12.23/2/4

vks
  • 67,027
  • 10
  • 91
  • 124

1 Answers1

3
^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$

You were close.Escape the ..See demo.

https://regex101.com/r/iJ7bT6/1

For java it would be

^\\d+(?:\\.\\d+)?\\/\\d+(?:\\.\\d+)?$
vks
  • 67,027
  • 10
  • 91
  • 124