The Answer to Life, the Universe, and Everything

Monday, November 06, 2006

Regex

Small sample to replace the regular expression..
Using Core API
String body = "\n";
String out;
Pattern pattern = Pattern.compile("class=\".*?\"");
Matcher matcher = pattern.matcher(body);
out = matcher.replaceAll("");
System.out.println(out);


Using Jakarta ORO
String body = "\n";
String out;
Perl5Util util = new Perl5Util();
out = util.substitute("s/ class=\".*?\"//g", body);
System.out.println(out);

No comments: