これがシナリオです。
String strText = "ABC abc Abc aBC abC aBc ABc AbC";
// Adding a HTML content to this
String searchText = "abc";
String strFormatted = strText.replaceAll(
"(?i)" + searchText,
"<font color='red'>" + searchText + "</font>");
これにより、すべての単語が小文字で、もちろん赤い色の文字列が返されます。私の要件はstrFormatted
、元の文字列と同じ大文字と小文字の文字列として取得することですが、Fontタグが必要です。
これを行うことは可能ですか?