派生自 projectDept/qhighschool

111
胡仁荣
2022-12-02 b94deda20c9abd2fb6248b831e10a620eb7daf68
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();
    }
}