I need help writing regex to remove a word using XSLT.
I need to change the output of my XML file's "detailpath" from:
/events/262/26207
...to simply:
262/26207
The XSL is:
<xsl:value-of select="detailpath"/>
How can I remove "/events/"?
Thanks in advance.
Do note that for your example (starting string) you could alse use this XPath 1.0 expression:
echo /events/262/26207 | sed -e 's|/events/||g'
This works in bash on Solaris and, with tweaking, should work in PHP, Javascript and Perl, to my knowledge.
Another XPath 1.0 solution (assuming there is only one instance of the string to replace) that would work regardless of where the text fragment is in the string:
The regex pattern would simply be
'/events/'
You can use it in an XSLT 2.0 replace() function call:
You can optionally specify flags