String - Replace

To replace a character in a string (in this instance hyphen) use the following :

  1. #set($key = "south-america")  
  2. $key.replaceAll("-"" ")  
  3. $key  
  5. <span style="text-transform:capitalize;"> $!{key} </span>  

$key will output "south america", you can always use text-transform as shown on line 4 above using either capitalize (Transforms the first character of each word to uppercase), uppercase (Transforms all characters to uppercase) or lowercase (Transforms all characters to lowercase). You can also use

To remove all html tags:

  1. #set($mystring = "<span>test span</span><p> test p</p>")  
  2. $mystring.replaceAll("</?[^>]+/?>""")  
comments powered by Disqus