lateapex
asked on
How to pull date out of String
Experts,
Using C# I need to pull a date out of a string. The date format will always be numbers in day/month/year style. Of course the day and months could be 1 or 2 digits each, the years are always 4 digit. I've been reading about regex's but i can't seem to get it right. The string contains lots of words in addition to the date. The date always has at least one space leading and trailing it.
Example: "Here we 7/15/1957 down the path"
Thanks!
Using C# I need to pull a date out of a string. The date format will always be numbers in day/month/year style. Of course the day and months could be 1 or 2 digits each, the years are always 4 digit. I've been reading about regex's but i can't seem to get it right. The string contains lots of words in addition to the date. The date always has at least one space leading and trailing it.
Example: "Here we 7/15/1957 down the path"
Thanks!
I'm hoping you know how to put it into .NET code
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window
Assumptions:To simplify the pattern, any month can have up to 31 days
Demo:
https://regex101.com/r/SkJcc2/2