0

I need to to process a delimited text with xslt that looks like:

abc@mail;#6896;#def@mail;#7467;#hij@mail

The output should be a mailto: link with all addresses and I need to throw away the numbers between them. I am working on Sharepoint, so can only use XSLT 1.0

Edit: I found this question from about 7 years ago, that is almost the same: "Regular expression"-style replace in XSLT 1.0 In my case, it doing exactly the opposite: keeping the numbers and throwing out the mail addresses. Can someone help me how to modify the code in the address? update: as a workaround, I added the delimiter as prefix to my text, and the template works perfect.

Community
  • 1
  • 1
vilmarci
  • 451
  • 10
  • 31
  • Possible duplicate of ["Regular expression"-style replace in XSLT 1.0](http://stackoverflow.com/questions/1043866/regular-expression-style-replace-in-xslt-1-0) – vilmarci Mar 31 '17 at 15:27

1 Answers1

0

This specifically looks for numbers rather than skipping every other item.

    <xsl:template name="ExtractNumbers">
    <xsl:param name="strInputString"/>

    <xsl:variable name="strCurrent" select="substring-before($strInputString, ';#')" />
    <xsl:variable name="strRemaining" select="substring-after($strInputString, ';#')" />

    <xsl:if test="$strCurrent != ''">
        <xsl:if test="string(number($strCurrent)) != 'NaN'">
            <xsl:value-of select="$strCurrent" />

            <xsl:if test="contains($strRemaining, ';#')">
                <xsl:text>, </xsl:text>
            </xsl:if>
        </xsl:if>

        <xsl:call-template name="ExtractNumbers">
            <xsl:with-param name="strInputString" select="$strRemaining"/>
        </xsl:call-template>
    </xsl:if>
</xsl:template>
NMGod
  • 1,937
  • 2
  • 12
  • 11