BenWhite
08-11-2008, 03:49 PM
Hi, I am having a little difficulty with split. I run into a problem when there are two delimeters in a row
Here is my ugly regular expression
contents = strContents.split(/\".\"|\"\n\"|\"\n\n\"/g)
one of the things it is looking for is "," (quotes included) but when two are in a row ",""," it doesn't give me an empty string for between them
basically the data is set up like this
"something","something else","another thing","","yet another thing"
I want the split to return an array with
0 - "something"
1 - "something else"
2 - "another thing"
3 - ""
4 - "yet another thing"
But it doesn't give me the empty string =( (index 3) and if something is not entered somewhere and there is an empty string it will get skipped and mess up my whole javascript program which is dumping stuff into a DB which won't be good if it messes up...
Thanks
p.s. I am using IE because the program is not cross browser compatible
Here is my ugly regular expression
contents = strContents.split(/\".\"|\"\n\"|\"\n\n\"/g)
one of the things it is looking for is "," (quotes included) but when two are in a row ",""," it doesn't give me an empty string for between them
basically the data is set up like this
"something","something else","another thing","","yet another thing"
I want the split to return an array with
0 - "something"
1 - "something else"
2 - "another thing"
3 - ""
4 - "yet another thing"
But it doesn't give me the empty string =( (index 3) and if something is not entered somewhere and there is an empty string it will get skipped and mess up my whole javascript program which is dumping stuff into a DB which won't be good if it messes up...
Thanks
p.s. I am using IE because the program is not cross browser compatible