(String url)
| 160 | } |
| 161 | |
| 162 | public static boolean isURL(String url){ |
| 163 | if (url == null ){ |
| 164 | return false ; |
| 165 | } |
| 166 | String regEx = "^(http|https|ftp)\\://([a-zA-Z0-9\\.\\-]+(\\:[a-zA-" |
| 167 | + "Z0-9\\.&%\\$\\-]+)*@)?((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{" |
| 168 | + "2}|[1-9]{1}[0-9]{1}|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}" |
| 169 | + "[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|" |
| 170 | + "[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-" |
| 171 | + "4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0" |
| 172 | + "-9\\-]+\\.)*[a-zA-Z0-9\\-]+\\.[a-zA-Z]{2,4})(\\:[0-9]+)?(/" |
| 173 | + "[^/][a-zA-Z0-9\\.\\,\\?\\'\\\\/\\+&%\\$\\=~_\\-@]*)*$" ; |
| 174 | Pattern p = Pattern.compile(regEx); |
| 175 | Matcher matcher = p.matcher(url); |
| 176 | return matcher.matches(); |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * 转义正则特殊字符 $()*+.[]?\^{},| |
no outgoing calls
no test coverage detected