0

I use XSLT 2. How I can replace pipe by aonther character ?

For exemple I have an element like this :

<list items="A1|A2|A3"/>

I want to have

<list items="A1,A2,A3"/>

I tried something like this, but not working

<xsl:variable name="result" select="replace(list/@items, '|', ',')"/>

What is problem ?

Valeriane
  • 936
  • 3
  • 16
  • 37

1 Answers1

1

The replace() function uses regex - and the pipe character is a special character in regex. Either escape the character:

<xsl:variable name="result" select="replace(list/@items, '\|', ',')"/>

or use the translate() function instead.

michael.hor257k
  • 113,275
  • 6
  • 33
  • 51