Java: Unterschied zwischen den Versionen

Aus wiki
Wechseln zu: Navigation, Suche
(Pattern Matching)
(Pattern Matching)
Zeile 2: Zeile 2:
 
== Regex ==
 
== Regex ==
 
=== Pattern Matching ===
 
=== Pattern Matching ===
 +
Named Matching
 
  private String getAccessToken(String responseURL) {
 
  private String getAccessToken(String responseURL) {
 
  String patternString = "http://localhost/client#(access_token%3D <http://localhost:8080/mobile-client#%28access_token%3D> (?<TOKEN>.+))%26token_type(.+%)";
 
  String patternString = "http://localhost/client#(access_token%3D <http://localhost:8080/mobile-client#%28access_token%3D> (?<TOKEN>.+))%26token_type(.+%)";

Version vom 28. Juli 2014, 16:04 Uhr

Code Snippets

Regex

Pattern Matching

Named Matching

private String getAccessToken(String responseURL) {
String patternString = "http://localhost/client#(access_token%3D <http://localhost:8080/mobile-client#%28access_token%3D> (?<TOKEN>.+))%26token_type(.+%)";
Pattern pattern = Pattern.compile(patternString);
Matcher matcher = pattern.matcher(responseURL);
matcher.find();
return matcher.group("TOKEN");
}