Thursday
20
Apr 2006

Java Regular expression matching

(1:21 pm) Tags: [General, Software, Projects]

Every once in a while, I get to write Java code. Having always used an external library (jakarta-regexp) to do regular expressions in my Java code, this constitutes my first try with the JDK 1.4 RegEx classes:

Pattern pattern = Pattern.compile(”^([0-9]*):.*”);
Matcher matcher = pattern.matcher(title);
if (matcher.matches()) {
result = matcher.group(1) + “: “;
}

Popularity: 77%

Comments: (0)