Search code examples
xsltxpathorbeonxforms

XSLT / XPath function to remove trailing characters


I have the situation whereby I am displaying an address in an XForm, this address comes to me pre formatted, but occasionally contains a couple of trailing commas, which I need to remove.

Here is my code:

    <xf:output id="Address-control" ref="$Address" >
        <xf:label>GP Address</xf:label>
    </xf:output>

Which, sometimes produces output like this:

 My House, My Road, My Town, , , , ,

I need something to strip out the trailing commas so the output becomes:

 My House, My Road, My Town

Thanks In Advance


Solution

  • Using replace($Address, '[\s,]+$', '') should remove any trailing mix of white space and commas.