Java regex | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Java regex

Hi everyone! Iā€™m not that good with regex and I was wondering if itā€™s possible to capture the first letter of each sentence in a paragraph (after .|?|!). I already did it with StringBuilder and for loop with if else statement. But would love to see how it would turn out with regex. Thanks in advance!

9th Oct 2022, 8:36 AM
Loulou
2 Respostas
+ 4
(?:^|(?:\.\s)|(?:\?\s)|(?:\!\s))(\w) \w = any lettre | = or ?:^ = start the sentence ?:\.\s = After . and Space ?:\!\s = After ! and Space ?:\?\s = After ? and Space https://rubular.com/r/OfDGF1iRKa1m5j
9th Oct 2022, 9:30 AM
Roland
Roland - avatar
+ 2
Thank you sm Roland Roland !
9th Oct 2022, 10:09 AM
Loulou