Redmine#3454: simple text manipulation functions

https://cfengine.com/dev/issues/3454

Acceptance tests included.

I will write docs if this is accepted.