String Replace / Regex

Last Updated: Feb 6, 2020
documentation for the dotCMS Content Management System

Here are some examples:

if you need to remove all html tags:

#set($mystring = "<span>test span</span><p> test p</p>")
$mystring.replaceAll("</?[^>]+/?>", "");

to remove, for example, only p tags

#set($mystring = "<span>test span</span><p> test p</p>")
$mystring.replaceAll("</?p[^>]*/?>", "");

 

On this page

×

We Dig Feedback

Selected excerpt:

×