velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geir Magnusson Jr. <ge...@optonline.net>
Subject Re: Using Backslash in Strings
Date Fri, 10 Oct 2003 21:04:50 GMT
On Friday, October 10, 2003, at 02:38 PM, Udo Borkowski wrote:

> How can I assign the String "\." (backslash-dot) to a property?
>
> When I use
>
>     #set($foo= "\.");
>
> I get an
>
>     Lexical error ... Encountered: "." (46), after : "\"\\"
>
> When I try to escape the backslash, ie write
>
>     #set($foo= "\\.")
>
> $foo contains backslash-backslash-dot.
>
> Any idea?

This happens because "" 'renders' the contents of the string and \ is 
the start of an escape for a reference.  This is a bug, I'm sure, but 
there's a quick work-around - just do :

#set($foo = '\.')

The single quote string means "don't interpolate this"...

>
> Thanks,
> Udo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geirm@optonline.net


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message