1

I'm trying to write an RE to find all mm/dd format

re = "((1[0-2])|(0?[0-9]))/(((1[0-9])|(2[0-9])|(3[0-1])|(0?[0-9])))"

It finds all mm/dd format but also gives things like,

11/22 in 12311/22213

and

10/22 in 1110/22213

How do I exclude the cases above?

Thanks

CD Smith
  • 6,579
  • 7
  • 38
  • 65
cheng
  • 6,305
  • 5
  • 23
  • 26

1 Answers1

1
(?<!\d)((1[0-2])|(0?[0-9]))/(((1[0-9])|(2[0-9])|(3[0-1])|(0?[0-9])))(?!\d)

Of course it'll match stuff like 02/31, but that's a start. I posted here a regex that matches only valid dates.

Community
  • 1
  • 1
dda
  • 5,760
  • 2
  • 24
  • 34