You should probably include the TT code you're trying to use as the
sample you included doesn't do what you think it does.
$text =~ s/[(.*?)]/@$1@/
is putting the characters ")", "(", ".", and "?" into a character class
and only trying to find the first single character match for any of
them.
Probably you want something more like
$text =~ s/\[([^\]]+)\]/[EMAIL PROTECTED]@/sg;
But again, if you include your template code and rationale, I'm
sure you'll get a great answer for what you're trying to do.
-Ashley
On Friday, October 21, 2005, at 09:53 PM, Mark S. wrote:
Hello!
Regular expressions are a powerful part of Perl. However, I
can't seem to get the same power in the toolkit. When I try the
virtual function 'replace', it doesn't seem to have the ability
to identify groups (identified by parenthesis () ) and insert
them into the output text the way perl does.
That is, if I'm looking for embedded tags in a string like:
"This is [my] embeded [string]"
with Perl I could say
$text =~ s/[(.*?)]/@$1@/
and have the text become
"This is @my@ embeded @string@"
But the virtual function 'replace' doesn't seem to know how to
find groups and then insert them this way. Or maybe it does, but
the syntax isn't documented well enough.
When I try to do it using the PERL directive, I get a message
saying that it doesn't like the tilde (~) in the text:
! file error - parse error - xyz.html line 24:
unexpected token (~)
So it doesn't like the tilde in the =~ structure when used
inside of a PERL/END directive.
Is there any way to get the regular expression parsing of Perl
into the toolkit?
Thanks!
Mark
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates