I have an input string as below:
john is a StartDate 10\11\2012 EndDate 15\11\2012 john is a boy john is StartDate john
I want to extract the two dates StartDate and EndDate from above string.
However, I can not just search for word StartDate because as seen towards the end of the string, StartDate may come as an independent word. I can not take first instance because there is no gaurantee that StartDate word with the dates will always be first.
So solution would be to search for pattern StartDate % EndDate % together. i.e. both StartDate and EndDate words together.
What would be the best way to achieve this?
One solution I can think of is for every instance of word StartDate, take the substring of next four words (including StartDate) and search for word EndDate in that subString. If its exists, we have the correct substring else go for the next instance of StartDate word and repeat the task.