This is a continuation of a question I asked earlier. I need to extract a date pattern, which is surrounded by the strings String1, String2, String3 String4. What I did was
Pattern pattern = Pattern.compile("(?<=String1\sString2\s(?:0?[1-9]|[12][0-9]|3[01])([- /.])(?:0?[1-9]|1[012])\\1(?:19|20)?\\d\\d?=\sString3\sString4)");
my date pattern is
(0?[1-9]|[12][0-9]|3[01])([- /.])(0?[1-9]|1[012])\\2(19|20)\\d\\d
which works fine but when trying to surround it with strings, I am facing trouble.
The date is in between String2 and String3. I am quite sure there is something wrong, as there is an error on my program saying invalid escape sequence but I can't figure it out. Any help is appreciated. Thanks in advance.