You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

str_replace()

Usage

str_replace(subject, search, replacement)

Description
Replaces each substring of the subject that matches the given regular expression with the given replacement.

Example

${str_replace("Hello Wrlod!", "Wrlod", "World")}
${str_replace("a 1 b 2 c 3 d 4", "\\s", "")}
${str_replace("a 1 b 2 c 3 d 4", "\\d", "")}
${str_replace("a 1 b 2 c 3 d 4", "\\d\\s", "")}
${str_replace("a 1 b 2 c 3 d 4", "[\\d\\s]", "")}

results in

Hello World!
a1b2c3d4
a b c d 
a b c d 4
abcd

Search results for "str_replace()"

str_replace()

Replaces each substring of the subject that matches the given regular expression with the given replacement.

str_replace(subject, search, replacement)