派生自 projectDept/qhighschool

胡仁荣
2023-07-18 885290e4d0d0c7fad3f538d901c616e49c3d6985
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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();
    }
}