I'm trying to create regexp with format "dd-dd-dd" in Swift
I came up with this :
(\d{1,2})(-)(\d{1,2})(-)(\d{1,2})
This pattern gives me correct result if the string is given as a whole. Example :
12-32-42 -> correct
2-32-1 -> correct
2--32-3 -> incorrect
I will be using this pattern in textfields. What I would like to know is if the typed string is heading towards positive regexp check. Example :
12 -> correct
-12-32 -> correct
12- -> correct
-12-- -> incorrect
I will be grateful for any help you can provide.
-12-32correct? It starts with-. I'd suggestlet pattern = "^\\d{1,2}(?:-(?:\\d{1,2}(?:-\\d{0,2})?)?)?$", see regex101.com/r/eHHG2l/1.