+ 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

19th Aug 2022, 11:19 AM
Vinay K
Vinay K - avatar
4 Antworten
+ 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.
19th Aug 2022, 11:43 AM
Ausgrindtube
Ausgrindtube - avatar
+ 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.
19th Aug 2022, 11:35 AM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Ausgrindtube I updated the code with my approach you can check and write me later if you have a better approach
19th Aug 2022, 12:42 PM
Vinay K
Vinay K - avatar
0
Ausgrindtube Yes but I wanna find all the words case-insensitively and replace them by case-sensitive is it possible
19th Aug 2022, 11:39 AM
Vinay K
Vinay K - avatar