replace和replaceAll

来源:互联网 发布:完美英语视听软件 编辑:程序博客网 时间:2024/05/15 02:16

作者:yan

如题:

String s="08-%-LC%";

String strRule=s.replaceAll("%","\\\\w*"); //基于正则表达式的替换要用replaceAll,不能用replace,否则将匹配失败。

Pattern p=Pattern.compile(strRule);

Matcher m=p.matcher("08-AU42TML-LC204AA");

原创粉丝点击