Reputation: 55
I have the following string where I would like to extract a subset of the string, up to and including a date.
Below is an example of the String:
This is text written on 12/19/2017 10:03:38 AM
I want to only return:
This is text written on 12/19/2017
I have tried the following (among many other attempt):
.+?(\d{1,2}/\d{2}/\d{4})
but this seems to return 12/19/2017 10:03:38
Thanks for any insight!
Upvotes: 0
Views: 31
Reputation: 1162
This should work. The problem is '/' is not escaped in your expression.
.+?(\d{1,2}\/\d{2}\/\d{4})
Upvotes: 2