how to validate if input is either a - or digits
Regular Expressions
1
Posts
1
Posters
8
Views
1
Watching
-
I am trying to verify if an input string either has a "-" or "123456" (any numeric input 0 or greater than 0).
(^([0-9])+|^(-)$)
Output scenarios: Input -> regex validation -- observation 10 -> true - OK - -> true - OK -10 -> false - OK 10- -> true - Not OK (either 10 or - is OK, 10- is not OK) 10-10 -> true - Not OK (again, having '-' between digits is not OK). 10- or 10-10 should return false / 0. Can you please correct this pattern?