Finding an exact string in xsl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • somanathan
    New Member
    • May 2007
    • 4

    #1

    Finding an exact string in xsl

    I have string like this
    jr:name=AdamAda mParoreAdamGilC hrist

    I want to find the exact string here.Say for e.g If I want Adam it should give me only that string.
    If I use contains(jr:nam e,'Adam')
    It will give true for all the three strings i.e AdamAdamParoreA damGilchrist.I want to do a exact string match.Is there any way to do like that?
  • dorinbogdan
    Recognized Expert Contributor
    • Feb 2007
    • 839

    #2
    Welcome to TheScripts TSDN....

    I'm not sure what output you need.
    In "Adam" case, what result do you expect?
    Please give more details.

    Comment

    • somanathan
      New Member
      • May 2007
      • 4

      #3
      Originally posted by dorinbogdan
      Welcome to TheScripts TSDN....

      I'm not sure what output you need.
      In "Adam" case, what result do you expect?
      Please give more details.
      Suppose if I am searching for AdamSachin which is not in the list ,the contains function will return true since AdamSachin which contains the string Adam in it...Got it??If you need more info that also I will give

      thanks for the quick reply

      Comment

      • dorinbogdan
        Recognized Expert Contributor
        • Feb 2007
        • 839

        #4
        Do you want to compare 2 strings to see if they match exactly?
        "Adam" = "Adam"
        and
        "Adam" != "AdamSachi" ?

        Then you must use <xsl:if test="jr:name=' Adam'">...</xsl:if>

        If it doesn't help enough, please give a clear example with the current result and expected result.

        Comment

        • somanathan
          New Member
          • May 2007
          • 4

          #5
          Originally posted by dorinbogdan
          Do you want to compare 2 strings to see if they match exactly?
          "Adam" = "Adam"
          and
          "Adam" != "AdamSachi" ?

          Then you must use <xsl:if test="jr:name=' Adam'">...</xsl:if>

          If it doesn't help enough, please give a clear example with the current result and expected result.

          This is my requirement..

          I have one string like this
          jr:rul=TISRecom mendedRecommend ed

          Sometimes the string will have only TISRecommended and some othertimes only Recommended.So when I search for Recommended within TISRecommended it will say Recommended is present.But TISRecommended and Recommended are two different strings. I need to find exactly which one of the string is present exactly??


          Hope u understand the situation now.

          Comment

          • dorinbogdan
            Recognized Expert Contributor
            • Feb 2007
            • 839

            #6
            If you know all matching strings, you could use xsl:choose to compare against each possible string.

            Comment

            Working...