I want to capture date and some other information from a string in java using regex.
I group my pattern as follows,
"( ( date_variation_1 | date_variation_2) (some_other_info) ) "
And now, I want to extract the matched string like this,
group0 - the whole match
group1 - date
group2 - some other info
My problem is that I need to use parentheses internally in date_variation_1, date_variation_2 and some_other_info and those parentheses will also be treated as group dividers.
Is there any easy work around for this, i.e. define some other special charter as outer group divider, instead of parentheses?
date_variation_1:
"(((?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday|Tues|Thur|Thurs|Sun|Mon|Tue|Wed|Thu|Fri|Sat))" // Day Of Week 1
+ "(\\s+)" // White Space 1
+ "((?:[0]?[1-9]|[1][012])[-:\\/.](?:(?:[0-2]?\\d{1})|(?:[3][01]{1}))[-:\\/.](?:(?:\\d{1}\\d{1})))(?![\\d])" // MMDDYY 1
+ "(\\s+)" // White Space 2
+ "((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\\s?(?:am|AM|pm|PM))?))"; // HourMinuteSec 1