Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

replace

Summary

Replaces elements in a string.

Usage

input|replace( offset [, length [, sequence1 [, sequence2 [, ...]]] ] )

Parameters

NameTypeDescriptionRequired
offset integer The offset to start replacing elements. Yes
length integer The number of characters that should be replaced. No
sequence1 any The sequence that will replace characters in input string. No
sequence2 any The sequence that will replace characters in input string. No

Returns

A replaced version of the input string.

Description

This operator replaces character(s) from the input string and a replaced version of input string will be returned. The "offset" parameter must be used to define the start of the portion that should be replaced. The "length" parameter can be used to define the number of characters that should be replaced. If length is omitted, the sequence(s) will be placed after the offset(like 'insert' operator).

Examples

Example 1

{'12345'|replace( 1, 2 )}

The following string will be returned: '145'.

Example 2

{'12345'|replace( 1 )}

The following array will be returned: '12345' .

Example 3

{'12345'|replace( 1, 2, 'ab' )}

The following array will be returned: '1ab45' .

Example 4

{{'12345'|replace( 1, 2, 'a', 'b', 'c' )}

The following array will be returned: '1abc45' .

Example 5

{'12345'|replace( 1, , 'abc' )}

The following array will be returned: '1abc2345' .

Geir Arne Waaler (19/08/2010 10:29 am)

Geir Arne Waaler (19/08/2010 10:46 am)


Comments

There are no comments.