Example usage for java.util.regex MatchResult group

List of usage examples for java.util.regex MatchResult group

Introduction

In this page you can find the example usage for java.util.regex MatchResult group.

Prototype

public String group(int group);

Source Link

Document

Returns the input subsequence captured by the given group during the previous match operation.

Usage

From source file:pl.otros.logview.parser.log4j.Log4jPatternMultilineLogParser.java

/**
 * Convert the match into a map./*www  . j ava  2  s .  com*/
 * <p>
 * Relies on the fact that the matchingKeywords list is in the same order as the groups in the regular expression
 * 
 * @param result
 * @return map
 */
private Map processEvent(MatchResult result) {
    Map map = new HashMap();
    // group zero is the entire match - process all other groups
    for (int i = 1; i < result.groupCount() + 1; i++) {
        Object key = matchingKeywords.get(i - 1);
        Object value = result.group(i);
        map.put(key, value);

    }
    return map;
}