I have a regex in Java:
Pattern pattern = Pattern.compile(<string>text</string><string>.+</string>);
Matcher matcher = pattern.matcher(ganzeDatei);
while (matcher.find()) {
String string = matcher.group();
...
This works fine, but the output is something like
<string>text</string><string>Name</string>
But I just want this: Name
How can I do this?
Capture the text you want to return by wrapping it in parenthesis, so in this example your regex should become
Then you can access the text that matched between the parenthesis with
The no-arg group method you are calling, returns the entire portion of the input text that matches your pattern, whereas you want just a subsequence of that, which matches a capturing group (the parenthesis).