public class AA {
        public static void main(String[]args){
            String url="http://sss//222/detail/10105";
            String pattern = ".*/\\d+";
            boolean isMatch = Pattern.matches(pattern, url);
            System.out.println("是否符合:" + isMatch);

            Pattern p=Pattern.compile("\\d+");
            Matcher m=p.matcher(url);
            while(m.find()) {
                System.err.println("获取正则表达式匹配到的结果:" + m.group());
                url = url.replace(m.group(),"数字");
            }
            System.err.println("" + url);
        }
}

 

相关文章:

猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
  • 2021-09-21
相关资源
相似解决方案