[RESOLVED] [2005] RegEx help - One more time!
OK, with much help from this forum, reading online and tweaking I have been trying to build a regex to capture dates within broader strings. The following:
((0?[1-9]|1[0-2])(/|-)(0?[1-9]|[1-2][0-9]|3[0-1])(/|-)(19|20)?[0-9][0-9])|((JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER) +([1-2][0-9]|3[0-1]|0?[1-9]),? +(19|20)?[0-9][0-9])
works for d/m/yy(yy), d-m-yy(yy), and MONTH d(,) yy(yy)
I have tried to add one more grouping to capture:
day Month Year (e.g., 10 FEBRUARY 2002)
but have failed. Any help would be greatly appreaciated.
Re: [2005] RegEx help - One more time!
Something along these lines?
([0-3]?\d\s*(JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER)\s*(19| 20)?[0-9][0-9])
Re: [2005] RegEx help - One more time!
(Isorfir) If I put a | at the end of my regex and append yours, it does not capture dd MONTH yyyy. Your regex does work by itself (i.e., it will capture the appropriate string). I don't know exactly how regex works, but does the second grouping consume something that the third grouping (yours) then can't pick up? I just can't get them all to work together.
Re: [2005] RegEx help - One more time!
I did what you said and mine seems to be working, see if it works for you.
((0?[1-9]|1[0-2])(/|-)(0?[1-9]|[1-2][0-9]|3[0-1])(/|-)(19|20)?[0-9][0-9])|((JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER) +([1-2][0-9]|3[0-1]|0?[1-9]),? +(19|20)?[0-9][0-9])|([0-3]?\d\s*(JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER)\s*(19| 20)?[0-9][0-9])
If it still doesn't work, show me the range of values you're trying to match.
Re: [2005] RegEx help - One more time!
That worked - I wish I knew why! Thanks so much.
Re: [2005] RegEx help - One more time!
As for yours not working, try looking to see what the differences were. I had to mess around with spacing and parenthesis.
A good website on RegEx is http://www.regular-expressions.info/