0

I have a table column of sentences and each sentence has a date that I want to get, all of the sentences are a bit different but the dates all come after "the due date is"

example:

"text text text the due date is 04/26/2017 text text text text"

how can I fetch only the dates that comes immediately after "due date is" I am wondering if I can fetch the 10 characters that comes after "due date is" since the dates are all 10 characters long

mikehuuuu
  • 111
  • 1
  • 1
  • 6
  • 1
    Yes you can do that assuming all of your data is very well-formatted. If you need to deal with data that is a lot less reliable, consider using regular expressions. – Ralph Caraveo Apr 26 '17 at 17:30
  • You may find [this answer for Regular Expressions for dates in `Python`](http://stackoverflow.com/questions/9978534/match-dates-using-python-regular-expressions#answer-9978804) useful. – zedd45 Apr 26 '17 at 17:32
  • to fetch the 10 characters that come after "due date is", you can split strings on a delimiter, using string "due date is" as the delimiter, grab the second-half of the splitted result, and slice the first 10 characters after the first space `[1:10]`...so altogether: `print mystring.split("due date is",1)[1][1:11]` may work – chickity china chinese chicken Apr 26 '17 at 17:41
  • (typo in my last comment `[1:10]` should be `[1:11]`), I based the code off of this answer [Get a string after a specific substring](http://stackoverflow.com/questions/12572362/get-a-string-after-a-specific-substring) – chickity china chinese chicken Apr 26 '17 at 18:24

0 Answers0