simplify

Summary

Returns a simplified version of the input string.

Usage

input|simplify( [char] )

Parameters

NameTypeDescriptionRequired
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.".

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2013 eZ Systems AS (except where otherwise noted). All rights reserved.