正则表达式记录
发布时间:2020-12-13 23:12:18 所属栏目:百科 来源:网络整理
导读:最近用到的做一下记录 String name = "10310";//以非0数字开头的数字串Pattern p = Pattern.compile("^[1-9]+d*");Matcher m = p.matcher(name);System.out.println(m.matches());//以数字.数字.数字.数字格式的串Pattern pt = Pattern.compile("d*[.]
最近用到的做一下记录 String name = "10310"; //以非0数字开头的数字串 Pattern p = Pattern.compile("^[1-9]+d*"); Matcher m = p.matcher(name); System.out.println(m.matches()); //以数字.数字.数字.数字格式的串 Pattern pt = Pattern.compile("d*[.]d*[.]d*[.]d*"); Matcher ma = pt.matcher("p=10.10.10"); System.out.println(ma.matches()); //以{内容},{内容}...{内容}格式的串 String test = "{fdfdfdfdfdfdfd}"; Pattern ptw = Pattern.compile("({[^{},]*}[,]*[nr]*){1,}"); Matcher maw = ptw.matcher("{gfdgfd}"); System.out.println(maw.matches()); //以数字,数字,....,数字格式的串 Pattern ptwe = Pattern.compile("[(d+),(d+)]*"); Matcher mawe = ptwe.matcher("333"); System.out.println(mawe.matches()); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读