- /**
- * URL检查<br>
- * <br>
- * @param pInput 要检查的字符串<br>
- * @return boolean 返回检查结果<br>
- */
- publicstaticboolean isUrl (String pInput) {
- if(pInput == null){
- returnfalse;
- }
- String regEx = "^(http https ftp)//://([a-zA-Z0-9//.//-]+(//:[a-zA-"
- + "Z0-9//.&%//$//-]+)*@)?((25[0-5] 2[0-4][0-9] [0-1]{1}[0-9]{"
- + "2} [1-9]{1}[0-9]{1} [1-9])//.(25[0-5] 2[0-4][0-9] [0-1]{1}"
- + "[0-9]{2} [1-9]{1}[0-9]{1} [1-9] 0)//.(25[0-5] 2[0-4][0-9] "
- + "[0-1]{1}[0-9]{2} [1-9]{1}[0-9]{1} [1-9] 0)//.(25[0-5] 2[0-"
- + "4][0-9] [0-1]{1}[0-9]{2} [1-9]{1}[0-9]{1} [0-9]) ([a-zA-Z0"
- + "-9//-]+//.)*[a-zA-Z0-9//-]+//.[a-zA-Z]{2,4})(//:[0-9]+)?(/"
- + "[^/][a-zA-Z0-9//.//,//?//'///////+&%//$//=~_//-@]*)*$";
- Pattern p = Pattern.compile(regEx);
- Matcher matcher = p.matcher(pInput);
- return matcher.matches();
- }
--转自
该贴由koei123转至本版2015-7-26 22:50:11