Reputation: 179
Trying to get the result of an html:
private static final String PATTERN = "(ReportSession=)[0-9A-Za-z]{24}";`
...
Pattern pattern = Pattern.compile(PATTERN);
Matcher matcher = pattern.matcher(".axd?ReportSession=frytm055l51aigbigh5xzrin\u");
if(matcher.find()){
textView1.setText(matcher.group(1));
}
The output is ReportSession=
but I need to get the whole ReportSession=frytm055l51aigbigh5xzrin
before the backslash. Any ideas?
Upvotes: 0
Views: 76
Reputation: 916
You denote groups with parentheses. You have only one inner group, that being (ReportSession=). If you need the whole pattern you can use:
matcher.group();
or
matcher.group(0);
Group zero denotes the entire pattern, so the expression m.group(0) is equivalent to m.group().
Source: http://docs.oracle.com/javase/1.5.0/docs/api/java/util/regex/Matcher.html#group%28int%29
Upvotes: 3