exclude line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smiley22
    New Member
    • Jun 2007
    • 54

    exclude line

    [javascript]

    hello, i just want to ask how will exclude column D (the BOLD entry) when its value is 1??? this example is a continous value [10000|12235PS|0 .0|0|0^10001|12 235PS|0.0|1|0^1 0000|12200SH|0. 0|1|0^10001|122 00SH|0.0|0|0^10 001|12232EA|0.0 |0|0^10001|1223 2EA|0.0|1|0^]

    a b c d e
    ----------------------------------
    10000|12235PS|0 .0|0|0^
    10001|12235PS|0 .0|1|0^ (this line will be remove)
    10000|12200SH|0 .0|1|0^ (this line will be remove)
    10001|12200SH|0 .0|0|0^
    10001|12232EA|0 .0|0|0^
    10001|12232EA|0 .0|1|0^ (this line will be remove)

    Thanks and regards to all you guys...
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The first step would be to use the String object's split method.

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5388

      #3
      hi ...

      have a look at the following example that wipes out the lines you wanted to be cleaned up:

      [CODE=javascript]var val = '10000|12235PS| 0.0|0|0^10001|1 2235PS|0.0|1|0^ 10000| 12200SH|0.0|1|0 ^10001|12200SH| 0.0|0|0^10001|1 2232E A|0.0|0|0^10001 |12232EA|0.0|1| 0^';

      var list = val.match(/([^\^]+)/g);
      var cleaned_list = [];

      for (var i = 0; i < list.length; i++) {
      var e = list[i];

      if (e.split('|')[3] != 1) {
      cleaned_list.pu sh(e + '^');
      }
      }

      alert(cleaned_l ist.join(''));
      [/CODE]
      kind regards

      ps: and of course ... acoder is right ... instead of the first match() you may use split() too ...

      Comment

      • smiley22
        New Member
        • Jun 2007
        • 54

        #4
        Originally posted by gits
        hi ...

        have a look at the following example that wipes out the lines you wanted to be cleaned up:

        [CODE=javascript]var val = '10000|12235PS| 0.0|0|0^10001|1 2235PS|0.0|1|0^ 10000| 12200SH|0.0|1|0 ^10001|12200SH| 0.0|0|0^10001|1 2232E A|0.0|0|0^10001 |12232EA|0.0|1| 0^';

        var list = val.match(/([^\^]+)/g);
        var cleaned_list = [];

        for (var i = 0; i < list.length; i++) {
        var e = list[i];

        if (e.split('|')[3] != 1) {
        cleaned_list.pu sh(e + '^');
        }
        }

        alert(cleaned_l ist.join(''));
        [/CODE]
        kind regards

        ps: and of course ... acoder is right ... instead of the first match() you may use split() too ...


        [CODE=javascript]

        hi guys,

        thanks for help, its a great idea..

        gudluck to all you guys!!

        [/CODE]

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by smiley22
          [CODE=javascript]

          hi guys,

          thanks for help, its a great idea..

          gudluck to all you guys!!

          [/CODE]
          I know we ask you to use code tags, but not everywhere! :)
          ...and you're welcome.

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5388

            #6
            Originally posted by acoder
            I know we ask you to use code tags, but not everywhere! :)
            ...and you're welcome.
            but it looks funny ... i think it was a joke ... ;)

            Comment

            Working...