How to separate values in a string and compare them?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • varshaP
    New Member
    • Feb 2008
    • 6

    How to separate values in a string and compare them?

    Hi.

    I have a string value which is combination of strings separated by a new line character '\n'.
    ie test1 + '\n' + test2 + '\n' + ..............

    I want to compare each string ie test1 .. test2 ..etc with the some another string..

    plese tell me how this can be done using javascript ?.......reply ..
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by varshaP
    Hi.

    I have a string value which is combination of strings separated by a new line character '\n'.
    ie test1 + '\n' + test2 + '\n' + ..............

    I want to compare each string ie test1 .. test2 ..etc with the some another string..

    plese tell me how this can be done using javascript ?.......reply ..
    [CODE=javascript]var test = test1 + '\n' + test2 + '\n' + ..............
    var testArray = test.split('\n' )[/CODE]

    Comment

    • varshaP
      New Member
      • Feb 2008
      • 6

      #3
      Originally posted by hsriat
      [CODE=javascript]var test = test1 + '\n' + test2 + '\n' + ..............
      var testArray = test.split('\n' )[/CODE]
      hi...

      thanks for ur reply.. but the code is working fine with hardcoded value.. But when i am tring to implement it with variable the '\n' is not getting splitted ..
      so it is comparing the two values along with '\n'..

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        Originally posted by varshaP
        hi...

        thanks for ur reply.. but the code is working fine with hardcoded value.. But when i am tring to implement it with variable the '\n' is not getting splitted ..
        so it is comparing the two values along with '\n'..
        post your code, then I can try...

        Comment

        • varshaP
          New Member
          • Feb 2008
          • 6

          #5
          Originally posted by hsriat
          post your code, then I can try...

          Hi .. ok I did it using search method ..thanks

          Comment

          Working...