String - Remove the last character of a string

If you need to remove the last character of a string then you can use the following little snippet, probably rarely used but incredibly useful when you need it.

  1. #set ($string = "/feeds/url/?type=1&type=2&q=$!{keyword}&")  
  2. #set ($stringLength = $string.length() - 1)  
  3. #set ($string = $string.substring(0,$stringLength))  
  4. $string  
comments powered by Disqus