limenitis

Untitled

Jan 14th, 2022
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. public class ClassName {
  2.  
  3.         /* code */
  4.  
  5.         // Pattern for recognizing a URL, based off RFC 3986
  6.         private static final Pattern urlPattern = Pattern.compile(
  7.                 "(?:^|[\\W])((ht|f)tp(s?):\\/\\/|www\\.)"
  8.                 + "(([\\w\\-]+\\.){1,}?([\\w\\-.~]+\\/?)*"
  9.                 + "[\\p{Alnum}.,%_=?&#\\-+()\\[\\]\\*$~@!:/{};' ]*)",
  10.                 Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
  11.  
  12.  
  13.         // function to check if qr contains url
  14.         public boolean isURL(String str){
  15.        
  16.                 if (urlPattern.matcher(str).matches()
  17.                         return true;
  18.                 else
  19.                         return false;
  20.        }
  21.  
  22.  
  23.        /* code */
  24. }
Advertisement
Add Comment
Please, Sign In to add comment