package com.qxueyou.scc.shorturl.util;
|
|
import java.util.regex.Matcher;
|
import java.util.regex.Pattern;
|
|
/**
|
* 短地址utils
|
* @author lihanqi
|
*
|
*/
|
public class ShortUrlUtils {
|
|
/**
|
* 验证网址Url
|
*
|
* @param 待验证的字符串
|
* @return 如果是符合格式的字符串,返回 <b>true </b>,否则为 <b>false </b>
|
*/
|
public static boolean IsUrl(String str) {
|
String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
|
Pattern pattern = Pattern.compile(regex);
|
Matcher matcher = pattern.matcher(str);
|
return matcher.matches();
|
}
|
}
|