日期:2014-05-20  浏览次数:20593 次

java 正则表达式的问题
如何替换   大小写的d  

regStr   =   "d?i?u "//这样能行吗?
strToReplace.replace(regStr, " <font   color= 'red '> d </font> ");

谢谢!

------解决方案--------------------
String strText = "DDddnihao ";
Pattern p = Pattern.compile( "d ", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(strText);
strText = m.replaceAll( " ");
System.out.println(strText);
------解决方案--------------------
没太看懂你要干什么,但是正则表达式不应该乱用,能用字符串操作简单解决的就用字符串操作:

" <font color= 'red '> d </font> ".replace( 'd ', 'D ');