首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

java 正则表达式的有关问题

2012-03-16 
java 正则表达式的问题如何替换大小写的dregStrd?i?u //这样能行吗?strToReplace.replace(regStr, f

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 ');

热点排行