By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,261 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,261 IT Pros & Developers. It's quick & easy.

exclude line

smiley22
P: 54
[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
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
The first step would be to use the String object's split method.
Oct 30 '07 #2

gits
Expert Mod 5K+
P: 5,390
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

smiley22
P: 54
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
Expert Mod 15k+
P: 16,027
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
Expert Mod 5K+
P: 5,390
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.