Java

Aus wiki
Wechseln zu: Navigation, Suche

Code Snippets

Regex

Pattern Matching

Named Matching <syntaxhighlight lang="java">

private @Nullable String getToken(@Nonnull String responseURL) {</pre>
String patternString = "http://www.example.com/example#(token%3D(?<TOKEN>.+))%26otherstuff(.+%)";
Pattern pattern = Pattern.compile(patternString);
Matcher matcher = pattern.matcher(responseURL);
if(matcher.find()){
return matcher.group("TOKEN");
}
return null;
}

</syntaxhighlight>