+ 1
How to replace multiple occurances of substrings in a string with different cases in Java
My replacing string value "string" In the string below "this is a string containing String and STrInG and stRIng and also sTRING and so on" How I want to replace "this is a (string) containing (String) and (STrInG) and (stRIng) and also (sTRING) and so on" I want to put "()" to all the occurrences of strings by case insensitive search and they have to be replaced with same case like "StRIng" should be "(StRIng)" and not simply "(string)" In Java https://code.sololearn.com/cUrraCaZSJQJ/?ref=app
4 Réponses
+ 3
I believe it should be possible.
I'll write you a message, save some space here (just clarifying questions).
And we'll see what we can work out.
+ 1
You're using a regex for not case sensitive search, is there an option to do a case sensitive search?
If so, then you'd need to provide the same outputs as you have above and then match them to it.
+ 1
Ausgrindtube I updated the code with my approach you can check and write me later if you have a better approach
0
Ausgrindtube Yes but I wanna find all the words case-insensitively and replace them by case-sensitive is it possible