Is this possible?

Comments

4 comments

  • Avatar
    Nathan H.

    What you are looking for is called substring-after


    Q: What does substring-after do? 

    A: Returns the remainder of string1 after string2 occurs in it

    Example and how you use it:

    substring-after(string1,string2)

    get all characters after a slash (/)
    Example: substring-after('12/10','/')
    Result: '10'

    get all characters after a space
    Example: substring-after('abcdefg123 193827462723', ' ')
    Result: '193827462723'

    Hope this helps.



    0
    Comment actions Permalink
  • Avatar
    rjohnson

    Thanks Nathan!

    Something I just noticed... Some of their SKU fields are only the UPC and some have characters preceding.. Would there be a way to check to see if the field had a space and if so, substring-after and if not then output the field as is?  I'm assuming if I substring-after and there is no space, I will get no output?

     

     

    0
    Comment actions Permalink
  • Avatar
    Nathan H.

    Rob,

    Yes. You can do something like this.

    <xsl:choose>
        <xsl:when test="contains(SKU, ' ')">
            <xsl:value-of select="substring-after(SKU, ' ')"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="SKU"/>
        </xsl:otherwise>
    </xsl:choose>
    0
    Comment actions Permalink
  • Avatar
    rjohnson

    Yep, working perfectly. 

    Very much appreciated. 

    0
    Comment actions Permalink

Please sign in to leave a comment.