I have unstructured string. From this I need to find the date.
Example: [expected inputs]
- “01/21/2012: text will be here”
- “;01/21/2012: text will be here”
- “text will be here. 01/21/2012: continues text”
- “text will be here. \n 01/21/2012: continues text”
- ”
text will be here 01/21/2012″
Note: Date can be any format such as 1st Jan 2012, 12-Jan-2012, 12/01/2012 etc
Any help greately appriciated.
I think regular expression will help.
First, write down all possible date format
second, convert them to regular expression
final, match the regular expression.
Be attention, regular expression do not support counting, so, you can only extract one, two, three….. a specify number of dates in one match, if the number of dates in the string is not fixed, you can dynamic generate regular expression or match multiple times.