// A regular expression that matches any white-space followed by a captured // non-white-space character, and any number of non white-space characters// separately captured, all at the end of the input.constpattern=/\s+(\S)(\S*)$/;constminify=sms=>// If the input SMS is already short enough, or has no white-space// characters, we just return it.sms.length<=160||sms.match(pattern)===null?sms:// If it does have white-space, we remove the last occurrence and// uppercase the captured character. Then we minify the resulting// SMS recursively.minify(sms.replace(pattern,(_,c,w)=>c.toUpperCase()+w))
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A recursive solution in JavaScript:
With comments: