Possible Duplicate:
regex replace all ignore case
如何获得所需的输出?
输入字符串-
"Software Industry. software Industry. SOFTWARE INDUSTRY. software industry. "
"software industry"
"*Software Industry*. *software Industry*. *SOFTWARE INDUSTRY*. *software industry*. "
最佳答案
您可以将replaceAll
与(?i)
一起使用,这将替换case-insensitive
。
String str = "Software Industry. software Industry. SOFTWARE INDUSTRY. "+
"software industry. "
str = str.replaceAll("(?i)(software industry)", "\\*$1\\*");
关于java - 正则表达式-搜索一个单词,并使用不区分大小写的单词替换为相同的单词,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12928265/