w3-tools.com - Free Webmaster Tools and Resources
 
w3-tools.com - Free Webmaster Tools and Resources
 Free Webmaster Tools and Resources

 



Smarty Manual

This manual is provided as a courtesy. It is not an official source. Please check smarty.php.net for updated information.

Smarty Manual

Smarty Manual

regex_replace

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

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

Example 5-14. regex_replace

<?php

$smarty
->assign('articleTitle'"Infertility unlikely to\nbe passed on, experts say.");

?>

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.

See also replace and escape.

Newsletter

Join to our newsletter and receive news and updates about our site.
Your name: 
E-mail address: 
Action: 
 

Hosted by

Search

Google
Web w3-tools.com

Links

  What is my IP? Find your IP address!     Valid XHTML 1.0 Transitional  
Copyright © 2006. by w3-tools.com. All rights reserved