Re: [SMARTY] regex_replace modifier

From: Date: Tue, 02 Dec 2003 19:19:57 +0000
Subject: Re: [SMARTY] regex_replace modifier
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10618@lists.php.net to get a copy of this message
On Mon, Dec 01, 2003 at 01:26:01PM +0100, Gabriel Birke wrote: > After some fiddling with the regex_replace modifier I found out that > the "$n" backreference doesn't work (Smarty 2.5), only the "\\n" > backreference. Maybe this should be mentioned in the manual to avoid > further wasting of time when others try to use this modifier. that's a valid point. the manual-page claims to be compatible to preg_replace() but here it isn't fully. > To display only a filename, without the path: > > {$entry.file|regex_replace:"'.*/([^/]+)$'":"$1"} > > doesn't work nope, because the $1 is subject to smarty's variable interpolation inside double-quotes *before* the plugins gets the parameters. > {$entry.file|regex_replace:"'.*/([^/]+)$'":"\\1"} not really, you mean {$entry.file|regex_replace:"'.*/([^/]+)$'":"\1"} > does. also {$entry.file|regex_replace:"'.*/([^/]+)$'":'$1'} works > With best regards > > Gabriel Birke BTW: for this particular case i suggest {$entry.file|basename} over regex_replace.

« previous php.smarty.general (#10618) next »