首页 > 解决方案 > 使用正则表达式的 URL 验证给出错误

问题描述

class Testimmutablestring1{

    public static void main(String[] args )
    {
        Pattern p = Pattern.compile("^(http://|https://)?(www.)([a-zA-Z0-9]+).[a- zA-Z0-9]*.[a-z]{3}.?([a-z]+)?$"));
        Matcher m;
        m=p.matcher(https://test.com:8080/wh-101);
    }
}

错误:tablestring1.java:3:错误:';' 预期 A-Z0-9]+).[a-zA-Z0-9]*.[az]{3}.?([az]+)?$")); ^ tablestring1.java:5: 错误: ')' 预期 m=p.matcher( https://test.com:8080/wh-101 ); ^ 2 个错误

谁能解释一下

标签: regexvalidationurlusing

解决方案


推荐阅读