I have to search due date in below sms that also contain billed date.
"Bill dated 27-May-18 for your airtel fixedline/broadband ID ##### has been sent at abc@abc.com from ebill@abc.com. Due amount: Rs 2,358.82, due date: 15-Jun-18"
there could be many different sms in which they may not have billed date or due date mentioned explicitly in the sms. So previously, we were just looking for a date format by regex,
"((\d{4}|\d{2})-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d{4}|\d{2}))|((\d{4}|\d{2})-\d{2}-(\d{4}|\d{2}))|((\d{4}|\d{2})\/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\/(\d{4}|\d{2}))|((\d{4}|\d{2})\/(\d{3}|\d{2})\/(\d{4}|\d{2}))|([0-3][0-9]((st)|(nd)|(rd)|(th))((\s)?)(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))"
It works well when there is only due date and no bill date. But in above sms it always returns bill date instead of due date.
I want to find a solution that it will always return me date like what above regex do or if there is any due date mentioned then it should return me date next to due date.
possible solution I see is
- check for due date - (due date: )
- if found return me date next to due date - (?<=due date: ).*
- else 2 not found then return me any date format that exist using the above mentioned regex