Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
163
rated 0 times [  167] [ 4]  / answers: 1 / hits: 30017  / 12 Years ago, thu, september 13, 2012, 12:00:00

I have a question relating to the answer on this post Javascript code to parse CSV data


I'm finding I get an extra "rn" on the end which I don't want to add to the array. I've tried to break out of the while loop...


The original working line is


 while (arrMatches = objPattern.exec( strData )){

but I need to break out if arrMatches = "rn"


while ((arrMatches[ 1 ] != "\r\n") && arrMatches = objPattern.exec( strData )){

but get an Invalid left-hand side in assignment error.


What is the correct syntax?


More From » javascript

 Answers
17

This approach should work, the only thing is that arrMatches should be between ( ) too, to avoid arrMatches being set to true from the second condition.



while ((arrMatches = objPattern.exec( strData )) && (arrMatches[ 1 ] != \r\n)) {

[#83104] Tuesday, September 11, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cassies

Total Points: 112
Total Questions: 99
Total Answers: 96

Location: Mexico
Member since Sun, Jul 25, 2021
3 Years ago
;