> > Simple, but does not work:
> > [% text.replace('(.).*','$1') %] expands to '$1'
>
> I think that needs to have doublequotes around the "$1" if you want it to interpret.
>
> [% text.replace('^(.).*',"$1") %]
>
Did you try that? I did, and I get
! file error - parse error: xyzzy.html line unknown: unexpected token (1)
[% $1 %]
This comes as no surprise for me since TT interpolates double
quotes as perl does - but there is no TT variable '1'.
It is not so easy to get $1 to work in the way required here
with the replace SCALAR_OP since perl does only one
level of variable interpolation.
The crucial line in context.pm reads
$str =~ s/$search/$replace/g;
...so $replace is interpolated by my parameter, but the $ in $1
is not interpolated. I replace my search string with literal '$1'.
--
Cheers,
haj