String replacement in fields

Hi,

This is in relation (and might be a work around) to the hugely popular thread: http://forum.percussion.com/showthread.php?t=2109&highlight=jsp

However, I think that this is sufficiently different to merit it’s own thread.

Is it anyway possible in a template to replace one string for another when extracting a field. For e.g., calling the macro: #field_if_set(’’ ‘body’ ‘’) and replacing each occurence of ‘string x’ by ‘string y’.

Any help is much appreciated.

Ultimately, calls to macros such as #field() and #field_if_set() in the end just output the value of the field passed to them using $sys.item.getProperty($fieldname).String. This is a standard java.lang.String object, hence can be modified using the methods described at http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html

Thanks for the quick reply.

The mistake I was making before posting was to look at replacing the strings after the macro is called (probably showing my ignorance of velocity by this), after posting I went away and had a look for those field macros. Was able to make some user-defined copies and do the replace in there. Seems to work fine. It’s probable that there is a better way of doing this, but as a first attempt I’ll be very content if it continues to work.

thanks