0

Java help code inserted

I was wondering how to concatenate or replace the letters this regex captures with the same letters but capitalized. Here is the code : https://code.sololearn.com/cqDR58xmUSEp/?ref=app Input : i like big dolls. i donā€™t like small dolls! do you? yes. wow! Output : I like big dolls. I donā€™t like small dolls! Do you? Yes. Wow! (donā€™t mind the example, brain empty) (shoutout to Roland for suggesting that regex)

9th Oct 2022, 10:14 AM
Loulou
3 Answers
+ 1
String result = matcher.replaceAll(mr -> mr.group().toUpperCase()); https://code.sololearn.com/cDkI486NNcep/?ref=app explanation: we can pass a function (lambda) argument to replaceAll, which converts a matchresult to a string for each occurrence https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Matcher.html#replaceAll(java.util.function.Function)
9th Oct 2022, 10:56 AM
Tibor Santa
Tibor Santa - avatar
0
It works! But is the link u shared working? Because I would love to read the explanation, especially since Iā€™ve never come across a lambda expression used like this
9th Oct 2022, 2:59 PM
Loulou
0
Yes, the link points to the Java language documentation
9th Oct 2022, 4:45 PM
Tibor Santa
Tibor Santa - avatar