[prev in list] [next in list] [prev in thread] [next in thread]
List: smarty-general
Subject: Re: [SMARTY] regex_replace modifier
From: messju mohr <messju () lammfellpuschen ! de>
Date: 2003-12-02 19:19:57
[Download RAW message or body]
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.
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic