Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ClassName {
- /* code */
- // Pattern for recognizing a URL, based off RFC 3986
- private static final Pattern urlPattern = Pattern.compile(
- "(?:^|[\\W])((ht|f)tp(s?):\\/\\/|www\\.)"
- + "(([\\w\\-]+\\.){1,}?([\\w\\-.~]+\\/?)*"
- + "[\\p{Alnum}.,%_=?&#\\-+()\\[\\]\\*$~@!:/{};' ]*)",
- Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
- // function to check if qr contains url
- public boolean isURL(String str){
- if (urlPattern.matcher(str).matches()
- return true;
- else
- return false;
- }
- /* code */
- }
Advertisement
Add Comment
Please, Sign In to add comment