четверг, 2 июля 2009 г.

Парсим тэги

final int flags = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
Pattern p = Pattern.compile("<h1>(.*)</h1>", flags);
Matcher m = p.matcher("some <h1>Hello World!</h1> text");
if (m.find()) {
  System.out.println(m.group(1));
}

* This source code was highlighted with Source Code Highlighter.