Java: Unterschied zwischen den Versionen

Aus wiki
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: «= Code Snippets = == Regex == === Pattern Matching === private String getAccessToken(String responseURL) { String patternString = "http://localhost:8080/mobile…»)
 
(Pattern Matching)
Zeile 3: Zeile 3:
 
=== Pattern Matching ===
 
=== Pattern Matching ===
 
  private String getAccessToken(String responseURL) {
 
  private String getAccessToken(String responseURL) {
  String patternString = "http://localhost:8080/mobile-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(.+%)";
 
  Pattern pattern = Pattern.compile(patternString);
 
  Pattern pattern = Pattern.compile(patternString);
 
  Matcher matcher = pattern.matcher(responseURL);
 
  Matcher matcher = pattern.matcher(responseURL);

Version vom 28. Juli 2014, 15:58 Uhr

Code Snippets

Regex

Pattern 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");
}