Package

Source Code of Test

import java.net.MalformedURLException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import placeholder.http.HttpRequest;

public class Test {
  public static void main(String[] args) throws MalformedURLException {
    HttpRequest request = new HttpRequest("http://wainox.de");
    request.send();
   
    String illegalChars = "[^\\\u0000-\\\u002C\\\u002E\\\u002F\\\u003A-\\\u0040\\\u005B-\\\u0060\\\u007B-\\\u007F]+";
    String urlPattern = "(" +
          "(?:" + // hostname
            "https?://" + illegalChars + "(?:\\." + illegalChars + ")*" +
            "|" +
            "www\\.(?:" + illegalChars + "\\.)+" +
            "(?:[a-z]{2,4}(?=\\b))" +
          ")" +
          "(?::\\d+)?" + // port
        ")";
   
    Pattern pattern = Pattern.compile(urlPattern, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(request.getResponseBody() + "s hTtp://wwainox.de/name.gif");
    while (matcher.find()) {
      System.out.println(matcher.group());
    }
  }
}
TOP

Related Classes of Test

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.