字谜验证器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了字谜验证器相关的知识,希望对你有一定的参考价值。
This is a snippet to validate anagrams of 'debit card'. It validates 'debit card' and 'bad credit'
//regular expression String patternStr = "(?=.*d.*d)(?=.*e)(?=.*b)(?=.*i)(?=.*t)(?=.*\s)(?=.*c)(?=.*a)(?=.*r)^..........$"; boolean b; Matcher matcher; Pattern pattern; pattern = Pattern.compile(patternStr);//compiles the regex //validates bad credit matcher = pattern.matcher("bad credit"); b = matcher.matches(); //validates debit card matcher = pattern.matcher("debit card"); b = matcher.matches();
以上是关于字谜验证器的主要内容,如果未能解决你的问题,请参考以下文章