-2

Based on this tei example, target='example.com#ktu1-1_ii_l13b-14_tmġyn' I would like to remove everything before (and including) # and everything after (and including) the last _, the first two underscores must be replaced by :. I have tried:

<xsl:variable name="verb" select="replace(replace(tokenize (@target, '\s+')!substring-after(., '#'), '_', ':'), '.+:.+.:', '')"/>

But this gives the opposite of the expected result (tmġyn) when the expected result should be ktu1-1:ii:l13b-14.

In advance, thanks so very much for your kind help.

Vanessa
  • 121
  • 12

2 Answers2

0

I found it, based on this answer regex to remove everything after the last dot in a file: :[^:]*$. So it works perfect:

<xsl:variable name="verb" select="replace(replace(tokenize (@target, '\s+')!substring-after(., '#'), '_', ':'), ':[^:]*$', '')"/>
Vanessa
  • 121
  • 12
-1

Using XSLT (2.0 or higher), you could do:

<xsl:value-of select="tokenize(substring-after(@target, '#'), '_')[position() lt last()]" separator=":"/>
michael.hor257k
  • 113,275
  • 6
  • 33
  • 51