Regular expression matching filter +

 

 

 

        RegEx = String "[^ A-zA-Z0-9]";   // regex 
        the Pattern of Pattern.compile P = (regEx);   // compiler 
        String STR = "& $% ABC (@ # 2. 1"; // to match the string 
        Matcher m = p.matcher (STR); // matching 
        System.out.println (m.matches ()); // matches 
        System.out.println (m.replaceAll ( "") trim . ()); // filter out the characters do not match

 

Guess you like

Origin www.cnblogs.com/june0816/p/11532944.html
Recommended