Regexp dates in numeric format removed when in paretheses

pull/14/head
Sam Bosley 12 years ago
parent 5e37e3bff5
commit 7249977f02

@ -231,29 +231,28 @@ public class TitleParser {
}
// for dates in the format MM/DD
Pattern p = Pattern.compile("(?i)\\b(1[0-2]|0?[1-9])(\\/|-)(3[0-1]|[0-2]?[0-9])(\\/|-)?(\\d{4}|\\d{2})?");
Pattern p = Pattern.compile("(?i)(\\(|\\b)(1[0-2]|0?[1-9])(\\/|-)(3[0-1]|[0-2]?[0-9])(\\/|-)?(\\d{4}|\\d{2})?(\\)|\\b)");
Matcher match = p.matcher(inputText);
if (match.find()){
Calendar dCal = Calendar.getInstance();
setCalendarToDefaultTime(dCal);
dCal.set(Calendar.MONTH, Integer.parseInt(match.group(1).trim())-1);
dCal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(match.group(3)));
if (match.group(5) != null && !(match.group(5).trim()).equals(""))
{
String yearString = match.group(5);
if(match.group(5).length()==2)
yearString = "20" + match.group(5);
dCal.set(Calendar.MONTH, Integer.parseInt(match.group(2).trim()) - 1);
dCal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(match.group(4)));
if (match.group(6) != null && !(match.group(6).trim()).equals("")) {
String yearString = match.group(6);
if(match.group(6).length() == 2)
yearString = "20" + match.group(6);
dCal.set(Calendar.YEAR, Integer.parseInt(yearString));
}
if (cal == null) {
cal = dCal;
}
else{
} else{
cal.set(Calendar.DAY_OF_MONTH, dCal.get(Calendar.DAY_OF_MONTH));
cal.set(Calendar.MONTH,dCal.get(Calendar.MONTH));
cal.set(Calendar.YEAR, dCal.get(Calendar.YEAR));
}
inputText = removeIfParenthetical(match, inputText);
}
HashMap<String, Integer> dayTimes = new HashMap<String, Integer>();

Loading…
Cancel
Save