|
|
|
|
| Smarty Manual |
|---|
| Prev | Chapter 5. Variable Modifiers | Next |
regex_replace| Parameter Position | Type | Required | Default | Description |
|---|
| 1 | string | Yes | n/a | This is the regular expression to be replaced. | | 2 | string | Yes | n/a | This 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. |
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|