派生自 projectDept/qhighschool

胡仁荣
2022-11-24 06d6372b451b964738cbfe2adb37e1da85d856ed
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();
    }
}