Hi Marcus, You should use Single quaotes, like
#set( $foo = '\' ) $foo $foo.length() outputs \ 1 Best Regards, trad-ex >"Nathan Bubna" <[EMAIL PROTECTED]> wrote: >> On 1/23/07, Marcus Sundman <[EMAIL PROTECTED]> wrote: >> > If I use "\" it spews out a parse error, and if I use "\\" the >> > result is two backslashes. I've tried two different versions (1.4 >> > and whatever version we had before I just upgraded to 1.4). >> > So, how can I use a backslash (needed for regexps, among others) in >> > strings in velocity? >> >> Can you share the code you're trying? I have no problem putting \ in >> my templates with Velocity 1.4. > >This causes velocity to give a parse error: >#set( $foo = "\" ) > >More specifically one of these: >org.apache.velocity.exception.ParseErrorException: Lexical error: >org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line >2, column 19. Encountered: "\n" (10), after : "\"\\\" )" > >This outputs "\\ 2": >#set( $foo = "\\" ) >$foo $foo.length() > > >- Marcus > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
