Tuesday, 17 September 2013

finding dates in long texts (strings) android

finding dates in long texts (strings) android

i have an appliaction in which i have to find dates in long strings (+-
500 words). The problem is one string can contain many date in many
formats.
My input can be for example :
"bla bla 11.09.2003 xxx 5/5/1993 and so on"
i already have many regular expressions for finding different dates and i
pass them to this method
public String extractWithRegEx(String regextype, String input) {
String matchedString = null;
if (regextype != null && input != null) {
Matcher matcher = Pattern.compile(regextype).matcher(input);
if (matcher.find()) {
matchedString = matcher.group(0);
if (matcher.groupCount() > 0) {
matchedString = matcher.group(1);
}
}
}
return matchedString;
}
Is there any library for android that handle this problem ? Or is there
better way for to this ?

No comments:

Post a Comment