I’m trying to retrieve the date from the line below using a single regEX. The date and time in the string below can change.
My Birthday is: Thu Jan 12 23:59:59 GMT 2012.
If I use this regEX
(?<=My Birthday is: ).+?(?=\.)
It will give me this.
Thu Jan 12 23:59:59 GMT 2012
But I’m looking for this..
Thu Jan 12 2012
How would I accomplish that with a single Regex Statement that works with .NET
The regular expression you’re after looks like this:
You’ll then simply need to join the two captured groups by referencing their respective indexes. I don’t know .NET, but it’d look like this in JavaScript:
The one thing you may need to change in the regular expression is the first
\d\d, depending on how 1–9 are displayed. If they’re displayed as 1–9 (rather than 01–09) you’ll need to use\d\d?instead.