Increase Exclamations and Convert Periods
Problem statement
Transform text in two steps:
- Add one additional exclamation mark to every existing consecutive run of
!characters. - Replace every period
.with one exclamation mark.
Function
transformPunctuation(text: String) → StringExamples
Example 1
text = "Hello. Nice to meet you!!"return = "Hello! Nice to meet you!!!"The period becomes !, and the existing run !! gains one more exclamation mark.