ez.no / exponential / documentation / reference / template operators / strings / simplify
$input_string|simplify( [char] )
| Name | Type | Description | Required |
|---|---|---|---|
| char | character | Char to simplify. | no |
simplified version of input string.
This operator transforms multiple consecutive characters into one. If you have a string with a lot of unnecessary whitespace (or dashes, whatever), you can use this operator to remove the duplicates leaving only a single copy of each character. The desired character to simplify can be specified using the optional char parameter. By default multiple spaces is removed. Regexp style is used to specify special characters, please refer to the table below:
\t tab (HT, TAB) \n newline (LF, NL) \r return (CR) \f form feed (FF) \a alarm (bell) (BEL) \e escape (think troff) (ESC)
Example 1
{"We don't need no whitespace!"|simplify}
returns the string "We don't need no whitespace!".
Example 2
{"this____string__is___annoying"|simplify( "_" )}
returns the string "this_string_is_annoying".
Comments