TopShelfCraft / Wordsmith

A plugin for Craft CMS to help you manage and manipulate text.
Other
30 stars 20 forks source link

[FR] Split string by unit, pattern, chunk length #21

Open michaelrog opened 5 years ago

michaelrog commented 5 years ago

In service to #3, #18, #20, and the chop filter in general, it'd be nice to have underlying methods for splitting text by various units — character, word, sentence, line, paragraph — and to expose those also as their own functions, e.g.:

split("This is a test.", unit='w')

...returns:

["This", "is", "a", "test."]

(Should we also offer a way to strip punctuation?)

Also, this function could include/extend functionality from: