Comunitatea PHP Romania
 

 
regex_replace

regex_replace

A regular expression search and replace on a variable. Use the preg_replace() syntax 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-15. regex_replace

<?php

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

?>

Where template is:

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

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

Will output:

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

See also replace and escape.

Ultimele discutii in forum RSS Forum

Ultimele articole Ultimele articole

Top membri

Pirahna Pirahna
acasa , in pat
carco carco
Bucuresti
Birkoff Birkoff
Bucuresti
Mascka Mascka
Braila
raul_ raul_
whooper whooper
Toronto ON
mihaitha mihaitha
Sibiu
gabysolomon gabysolomon
Bacau
oriceon oriceon
Constanta
garlicinicolae garlicinicolae

Newsletter


Email:
 inscriere
 renuntare
 
 Arhiva newsletter

Parteneriat

Copyright © 2001-2008 PHP Romania Add PHPRomania to Google Add PHPRomania to Del.icio.us Add PHPRomania to Stumbleupon Add PHPRomania to Yahoo! Add PHPRomania to Digg Add PHPRomania to Blink Loans | Mortgage Brokers Directory | Free Ringtones | Video Codes | Web Advertising
Ads: Partener Way2Web Nework: gazduire web | inregistrare domenii | web design | imobiliare | web hosting
Powered by Simplis