Start a new topic

regular expression - extract month from date

Hi there,

 

Is anyone able to help with the following request: I'm trying to use regular expression to extract the month from a date of DD/MM/YYYY.

 

So far, I have

^(.{3}).(.*)

^(.{3})(.)(.*)$

^(\d{2}).*

which all provide the day = DD

But I'm looking for the expression that only returns the month = MM

Does anybody know how to do this?

Many thanks,

Christine


Hi Christine,

The easiest way to go about this is separate the day, month, and year into 3 groups, then output only the group that is the month.

Value to match on (\d{1,2})/(\d{1,2})/(\d{4})
Replacement value $2

Thanks,

John

Hi John,

 

That's fantastic, thank you very much for this, 100% works. Much appreciated! Was driving us all mad!

 

Many many thanks

Christine

Login or Signup to post a comment