String.toCivilized
toCivilized($textType='comment') -> string
Description
Fix obnoxious patterns in a user-submitted string, by applying these filters:
- Convert excess caps to lower-case.
- Truncate extremely long words.
- Truncate excessive repetition. (e.g.
.....,?????) - Shrink excess whitespace and newlines.
- Filter out profanity.
- Expand casual abbreviations (e.g. 'pls' → 'please')
$comment = 'AAAAAAAAAH HELP ME FIX THIS!!!!!!!!!'
$comment.toCivilized('comment')
//= 'Aaah help me fix this!'
$title = 'HOW TO ORDER BOOK PLS????'
$title.toCivilized('title')
//= 'How To Order Book Please?'