Project

Profile

Help

Escaping curly braces (replace function)

Added by Anonymous over 16 years ago

Legacy ID: #4832908 Legacy Poster: Chuck (cawillwe)

Hello, I can't seem to get the escaping right to replace the curly braces characters {}... <xsl:value-of select="replace($entered_string, 'magic regular expression', 'replacing with two brackets')"/> I'm using Saxon9B (with Oxygen) Tried: <xsl:value-of select="replace($entered_string,'{','{{')"/> Oxygen validates this, but when I run it, I get "Invalid replacement string in replace(): \ character must be followed by \ or $" If I try: <xsl:value-of select="replace($entered_string,'{{','{{{{')"/> Oxygen won't validate, I get "Error at character 0 in regular expression "{{": expected end of string Apologies if this is the wrong forum... Thanks, Chuck


Replies (2)

RE: Escaping curly braces (replace function) - Added by Anonymous over 16 years ago

Legacy ID: #4833201 Legacy Poster: Michael Kay (mhkay)

The curly brace needs to be escaped as { in the regular expression, but it does not need to be (and must not be) escaped in the replacement string. So it's replace($in, '{', '{{')

RE: Escaping curly braces (replace function) - Added by Anonymous over 16 years ago

Legacy ID: #4833276 Legacy Poster: Chuck (cawillwe)

Thanks much!

    (1-2/2)

    Please register to reply