Yes, I know that solution, but lets say the text comes from a database
or some other source rather than being hardcoded in the template. Is
there a more general/correct solution than something along the lines of:
b.replace('_err_', a.replace('$','\$'));
or its correct equivalent - figuring out what backslashes are needed
there makes my head hurt!
On 21/04/2010 16:30, Andy Wardley wrote:
> On 21/04/2010 14:51, Travis Basevi wrote:
>> [%
>> a = 'this problem will cost me $50 million to fix';
>> b = 'WARNING:_err_';
>> b.replace('_err_', a);
>> %]
>
> The '$50' is being interpreted as a back-reference to the 50th
> set of capturing parens (of which there are none).
>
> Escaping the '$' with a backslash will fix it:
>
> a = 'this problem will cost me \$50 million to fix';
>
> Problem solved! How do I claim my $50 million? :-)
>
> A
>
>
>
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
>
This email, including attachments may be privileged, confidential and is
intended exclusively for the addressee. The views expressed may not be official
policy, but the personal views of the originator. If you have received this
email in error please notify the sender and delete it from your system. Emails
are not secure and may contain viruses. No liability can be accepted for
viruses that might be transferred by this email or any attachment.
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates