Web page hosting and cheap domain registration register services
 

Sponsers:

 

 

 

Smarty Manual
PrevChapter 5. Variable ModifiersNext

regex_replace

Parameter PositionTypeRequiredDefaultDescription
1stringYesn/aThis is the regular expression to be replaced.
2stringYesn/aThis is the string of text to replace with.

A regular expression search and replace on a variable. Use the syntax for preg_replace() from the PHP manual.

Example 5-14. regex_replace

<?php

$smarty
= new Smarty;
$smarty->assign('articleTitle', "Infertility unlikely to\nbe passed on, experts say.");
$smarty->display('index.tpl');

?>

Where index.tpl is:

{* replace each carriage return, tab and new line with a space *}

{$articleTitle}
{$articleTitle|regex_replace:"/[\r\t\n]/":" "}

This should output:

Infertility unlikely to
be passed on, experts say.
Infertility unlikely to be passed on, experts say.

PrevHomeNext
nl2brUpreplace
 

 

 

 

Search engine submission by Seosubmit.com | Cheap domain by Cheap Domain Registrar  

Disclaimers: This document is provided as free service for the benefits of Active-Venture.com's web hosting customers only.

 
Quotes: The cat lives alone, has no need of society, obeys only when she pleases, pretends to sleep that she may see more clearly, and scratches everything on which she can lay her paw.