我正在尝试找到“aaa”的模式并将其替换为“b”,例如使用 indexOf 但它无法正常工作:
private boolean matchCase;
private boolean wholeWords;
private void containsSearchValue(String currentValue, List<MnvrFindContainer> foundList, String textToFind, int i, int j)
{
if .....
else if (matchCase && wholeWords && currentValue.contains(textToFind))
{
String s = currentValue;
String pattern = textToFind;
int index = 0;
int lengthOfPattern = 0;
do
{
index = s.indexOf(pattern, index + lengthOfPattern);
lengthOfPattern = pattern.length();
MnvrFindContainer fContainer = new MnvrFindContainer();
fContainer.row = i;
fContainer.column = j;
foundList.add(fContainer);
}
while (index > -1);
}
}