Sachin Mittal wrote:
> Hi,
> I am having this weired problem.
> This is the velocity line
> #set($esctext = $text.replaceAll("\\s+",""))
>
> This should suppose to remove all the whitespaces in the text.
> If I execute same in java code it works fine.
>
> However if I use it in velocity code the same not working, we get $esctext
> same as $test.
>
> Now when I change the velocity code to
> #set($esctext = $text.replaceAll(" ",""))
> this is working all fine, and if the $text has single whitespaces, then this
> gets replaced.
>
> Thus bottom line is that replaceAll method is working fine and there is some
> issue with regexp only.
>
> Could someone please let me know if this is general issue with velocity or
> something to do with xwiki.
> Any reasons why its happening so?
The reason is \\, which is used by too many things. Try using a variable that
contains \, for example:
#set($bk = $escapetool.b)
#set($esctext = $text.replaceAll("${bk}${bk}s+", ""))
(if you are using an XWiki version that has the escape tool)
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs