Skip to the content
Documentation

simplify

No ratings yet

Summary

Returns a simplified version of the input string.

Usage

input|simplify( [char] )

Parameters

Name Type Description Required
char character The character that should be simplified. No.

Returns

A simplified version of the input string.

Description

This operator takes a string as the input parameter. It transforms multiple consecutive characters into one. The operator can be used to remove the duplicates as it leaves only a single copy of each character. It is possible to specify only one character that should be simplified, this can be done using the optional "char" parameter. By default, the operator removes multiple spaces. Special characters must be specified using regular expression style, please refer to the table below.

Character Description
\t Tab (HT, TAB)
\n Newline (LF, NL)
\r Return (CR)
\f Form feed (FF)
\a Alarm / bell (BEL)
\e Escape / think troff (ESC)

Examples

Example 1
{'We    don't    need   no whitespaces!'|simplify()}

The following output will be produced: "We don't need no whitespaces!".

Example 2
{'This____string__is___annoying.'|simplify( '_' )}

The following output will be produced: "This_string_is_annoying.".

Contributors

Comments

Add a comment

Comments are read by a moderator before they appear.