Ejemplo n.º 1
0
 @Test
 public void findStructuredGroups() {
   Pattern pattern = compile("\\{\\w*\\}");
   Matcher matcher = pattern.matcher("/{parameter1}/some/path/{parameter2}/end");
   while (matcher.find()) {
     log.info("Found parameter: [" + matcher.group().replaceAll("\\{|\\}", "") + "]");
   }
   String output = matcher.replaceAll("(.*)");
   log.info("Replaced output: [" + output + "]");
 }
Ejemplo n.º 2
0
 @Test
 public void findStructuredGroupsWithParenthesis() {
   Pattern pattern = compile("\\([^\\)]*\\)");
   Matcher matcher =
       pattern.matcher("Some sentance (parameter 1d) /some/path/ (parameter 2 ) /end");
   while (matcher.find()) {
     log.info("Found parameter: [" + matcher.group().replaceAll("\\(|\\)", "") + "]");
   }
   String output = matcher.replaceAll("(.*)");
   log.info("Replaced output: [" + output + "]");
 }