Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sachin 10 posts 10 karma points
    Jul 03, 2009 @ 08:45
    Sachin
    0

    Tricky String Manupulation!

    Hello,</span></span></span> </span>I have a string something like this: <span style="mso-spacerun: yes;"> </span>“MyFirstName_SecondName_2_c93adea6_948_49549f23_d6e.txt”. </span></span></span>I wish to remove the string “_2_c93adea6_948_49549f23_d6e.txt” </span>i.e. the string from last <span style="mso-spacerun: yes;"> </span>5 underscores (“_’) and wish to keep “MyFirstName_SecondName”. The 'part to keep' may not have any underscore(e.g. MyFirstName only) </span></span></span> </span>I have spent lot of time but I am not able to write customized function which can substring the string as per my requirement.</span></span></span> </span>Regards,</span></span></span>Sachin</span></span></span>

  • Sachin 10 posts 10 karma points
    Jul 03, 2009 @ 08:46
    Sachin
    0

    Hello,

    Sorry for the previous post. Its not readable.

    I have a string something like this:  “MyFirstName_SecondName_2_c93adea6_948_49549f23_d6e.txt”.
    I wish to remove the string “_2_c93adea6_948_49549f23_d6e.txt”  i.e. the string from last  5 underscores(“_’) and wish to keep “MyFirstName_SecondName”. The part to keep may not have any underscore(e.g. MyFirstName only)

    I have spent lot of time but I am not able to write customized function which can substring the string as per my requirement.

    Regards,
    Sachin

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 03, 2009 @ 09:08
    Morten Bock
    0

    Try this:

    <xsl:variable name="stringparts" select="umbraco.library:Split('MyFirstName_SecondName_2_c93adea6_948_49549f23_d6e.txt', '_')" />
    <xsl:value-of select="$stringparts/values/value[1]"/>_<xsl:value-of select="$stringparts/values/value[2]"/>
  • Sachin 10 posts 10 karma points
    Jul 03, 2009 @ 14:33
    Sachin
    0

    Hello Morten,

    Actually I do not wish to use the functionnality provided by <span style="color: #008800;">umbraco library. So how can Iit in that case.</span>

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 03, 2009 @ 14:45
    Morten Bock
    0

    Why not? Is it not for an umbraco solution?

  • Sachin 10 posts 10 karma points
    Jul 06, 2009 @ 08:43
    Sachin
    0

    Hello Morten,

    I get following Error while using it. :

    Error in XPath Expression.

    Undefined namspace prefix - 'unbraco.library'.

  • Tommy Poulsen 514 posts 708 karma points
    Jul 06, 2009 @ 08:51
    Tommy Poulsen
    0

    Sachin, you need to include the umbraco.library namespace in your xslt, e.g. something like this:

    <xsl:stylesheet 
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library"
        exclude-result-prefixes="msxml umbraco.library">

     

    >Tommy

     

Please Sign in or register to post replies

Write your reply to:

Draft