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,597
  • 7
  • 40
  • 66
cheng
  • 6,596
  • 6
  • 25
  • 27

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
  • 6,030
  • 2
  • 25
  • 34