I need to write a regular expression to remove a word using XSLT.
I need to change the output of my XML file "detailpath" from:
/ Events / 262/26207
... simply:
262/26207
XSL:
<xsl:value-of select="detailpath"/>
How to remove "/ events /"?
Thanks in advance.
The regex pattern will be simple '/events/'
'/events/'
You can use it in XSLT 2.0 replace () function calls:
<xsl:value-of select="replace(detailpath,'/events/','')"/>
Functionreturns the string xs:, which is obtained by replacing each disjoint substring $ input that matches the given pattern $ with the occurrence of the replacement $ string.
returns the string xs:, which is obtained by replacing each disjoint substring $ input that matches the given pattern $ with the occurrence of the replacement $ string.
You can specify flags
fn:replace( $input as xs:string?, $pattern as xs:string, $replacement as xs:string) as xs:string fn:replace( $input as xs:string?, $pattern as xs:string, $replacement as xs:string, $flags as xs:string) as xs:string
, ( ) XPath 1.0:
substring(detailpath, 9 * starts-with(detailpath,'/events/'))
Another XPath 1.0 solution (assuming there is only one instance of the replacement string) that will work no matter where the text fragment is in the string:
<xsl:value-of select="concat(substring-before(detailpath,'/events/'), substring-after(detailpath,'/events/'))" />
echo / events / 262/26207 | sed -e | / events / || g '
This works in bash on Solaris and, given the settings, should work in PHP, Javascript and Perl, as far as I know.
Source: https://habr.com/ru/post/1786996/More articles:JSON output from page - jsonFast merge merge in git - gitButtons activate / deactivate elements in the list (difficult case) - jqueryConvert XSLT 1.0 to 2.0 - xsltLucene TermFrequenciesVector - javaIs there a good block cipher that supports small block sizes? - cryptographyTrying to download a new orientation change - iosHow to add multi-domain support in CodeIgniter? - phpIn Java, can these / super keywords represent anything other than classes / enumerations? - javaWhere to find Facebook cookie? - javascriptAll Articles