[Hippo-cms7-user] jstl replace using regular expressions

Ard Schrijvers a.schrijvers at onehippo.com
Wed Nov 4 09:34:24 CET 2009

Crossposting to hst list, as this thread belongs there.

Suppose, you are having the 'internal links and images' resolved RTE
field as follows:

<hst:html var="html" hippohtml="${document.html}"/>

Now, you want to format this html. As you say, doing so in jsp is a
hell of a job. So, why don't you create in your project, your own
tags, for example:


In this tld, you define a tag, for example 'htmltransformer' which can
have as input value a string.


<hst:htmltransformer var="transformed" untransformed="${html}">

Now, you htmltransformer tag can do all the java stuff you want, and
put the transformed result in 'transformed'. Then in your jsp, you can
use ${transformed}

This is all just plain jsp development.

Regards Ard

On Tue, Nov 3, 2009 at 7:47 PM, Edwin Benneheij <ettepet at gmail.com> wrote:
> Hi,
> I would like to do some replacements in the resolved html from the Xinha
> RTE-fields, using an custom taglib.
> The only function that I could find, that can do some replacement-jobs, is
> fn:replace
> Unfortunately, this function only accepts straight ahead strings as an
> input.
> For example:
> Remove all inline-styles from a tag:   <just_a_tag style="xxxxxx" ....>
> In Java a regular expression can be used:
>        String source = html.getContent();
>        Pattern pattern = Pattern.compile("(<[^<>]*) style=\"[^<>\"]*\"");
>        String replacement = "$1";
>        Matcher m = pattern.matcher(source);
>        String formattedString = m.replaceAll(replacement);
> Can someone give me a working example how to manage this in my custom
> taglib?
> Thanks in advance,
> Edwin
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/community.html

More information about the Hippo-cms7-user mailing list