Monday, March 10, 2014

Notes on Regular Expression

\\b[G1-4][NS]-[A-Z]\\d\\d\\b

Pattern errorPattern = Pattern.compile(".*Exception:([^<>]*?)for file");
Matcher matcher = pattern.matcher(errorPattern);
// check all occurance
while (matcher.find()) {
  System.out.print("Start index: " + matcher.start());
  System.out.print(" End index: " + matcher.end() + " ");
  System.out.println(matcher.group());

}
text = text.replaceAll("\\p{Punct}", " ");

Squeeze all lines into one line:

replace \r\n with space

No comments:

Post a Comment