469,330 Members | 1,286 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

exclude line

smiley22
[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|12235PS|0.0|1|0^10000| 12200SH|0.0|1|0^10001|12200SH|0.0|0|0^10001|12232E A|0.0|0|0^10001|12232EA|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...
Oct 30 '07 #1
5 1393
acoder
16,027 Expert Mod 8TB
The first step would be to use the String object's split method.
Oct 30 '07 #2
gits
5,390 Expert Mod 4TB
hi ...

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

Expand|Select|Wrap|Line Numbers
  1. var val = '10000|12235PS|0.0|0|0^10001|12235PS|0.0|1|0^10000| 12200SH|0.0|1|0^10001|12200SH|0.0|0|0^10001|12232E A|0.0|0|0^10001|12232EA|0.0|1|0^';
  2.  
  3. var list = val.match(/([^\^]+)/g);
  4. var cleaned_list = [];
  5.  
  6. for (var i = 0; i < list.length; i++) {
  7.     var e = list[i];
  8.  
  9.     if (e.split('|')[3] != 1) {
  10.         cleaned_list.push(e + '^');
  11.     }
  12. }
  13.  
  14. alert(cleaned_list.join(''));
  15.  
kind regards

ps: and of course ... acoder is right ... instead of the first match() you may use split() too ...
Oct 30 '07 #3
hi ...

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

Expand|Select|Wrap|Line Numbers
  1. var val = '10000|12235PS|0.0|0|0^10001|12235PS|0.0|1|0^10000| 12200SH|0.0|1|0^10001|12200SH|0.0|0|0^10001|12232E A|0.0|0|0^10001|12232EA|0.0|1|0^';
  2.  
  3. var list = val.match(/([^\^]+)/g);
  4. var cleaned_list = [];
  5.  
  6. for (var i = 0; i < list.length; i++) {
  7.     var e = list[i];
  8.  
  9.     if (e.split('|')[3] != 1) {
  10.         cleaned_list.push(e + '^');
  11.     }
  12. }
  13.  
  14. alert(cleaned_list.join(''));
  15.  
kind regards

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


Expand|Select|Wrap|Line Numbers
  1.  
  2. hi guys,
  3.  
  4. thanks for help, its a great idea..
  5.  
  6. gudluck to all you guys!!  
  7.  
  8.  
Oct 31 '07 #4
acoder
16,027 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1.  
  2. hi guys,
  3.  
  4. thanks for help, its a great idea..
  5.  
  6. gudluck to all you guys!!  
  7.  
  8.  
I know we ask you to use code tags, but not everywhere! :)
...and you're welcome.
Oct 31 '07 #5
gits
5,390 Expert Mod 4TB
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 ... ;)
Oct 31 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Han | last post: by
11 posts views Thread by rbt | last post: by
3 posts views Thread by Dheeraj | last post: by
15 posts views Thread by could ildg | last post: by
1 post views Thread by John Dalberg | last post: by
2 posts views Thread by Arsen V. | last post: by
1 post views Thread by AntiChrist | last post: by
10 posts views Thread by Simon Brooke | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.