473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1548
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

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

Similar topics

3
by: Han | last post by:
Yet another newbie regular expression question (I swear, I'm learning!) I have a simple pattern that captures an anchor tag: (<a.*?</a>) It works great. I would now like to modify this to...
11
by: rbt | last post by:
Is there an easy way to exclude binary files (I'm working on Windows XP) from the file list returned by os.walk()? Also, when reading files and you're unsure as to whether or not they are ascii...
3
by: Dheeraj | last post by:
I am a conflicting definition message when i am migration the roguewave c++ libraries. below is the message.i would like to know how to exclude the conflicting functions. thanks in advance...
15
by: could ildg | last post by:
In re, the punctuation "^" can exclude a single character, but I want to exclude a whole word now. for example I have a string "hi, how are you. hello", I want to extract all the part before the...
1
by: John Dalberg | last post by:
In VS 2003, I was able to exclude full folders from a project but I can't do the same in VS 2005. I can exclude files but not folders. I prefer to exclude at the folder level because the folder...
2
by: Arsen V. | last post by:
Hi, How to exclude the App_Data directory from Visual SourceSafe? It appears that Vs 2005 automatically adds the App_Data directory with the large binary MDF and LOG files to the Visual...
1
by: AntiChrist | last post by:
In VS 2005 if you exclude files from a project, it actually renames the file to filename.exclude. In previous versions, it just left the file alone but excluded it. If you have a very large...
10
by: Simon Brooke | last post by:
I'm struggling to understand what 'exclude-result-prefixes' does and is for; the language of the standard http://www.zvon.org/xxl/XSLTreference/W3C/xslt.html#literal-result-element is not...
2
by: jonathan184 | last post by:
How to exclude lines from a txt file that start with a # Hi basically my script works fine. I wanted to add some comments in my config file but it is reading in the comment lines to. So...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.