Parsing plain data with Javascript (JQuery)
Posted
by
Angelus
on Stack Overflow
See other posts from Stack Overflow
or by Angelus
Published on 2010-12-30T18:55:53Z
Indexed on
2010/12/30
19:54 UTC
Read the original article
Hit count: 217
JavaScript
|jQuery
Well , I have this text in a Javascript Var:
GIMP Palette
Name: Named Colors
Columns: 16
#
255 250 250 snow (255 250 250)
248 248 255 ghost white (248 248 255)
245 245 245 white smoke (245 245 245)
220 220 220 gainsboro (220 220 220)
255 250 240 floral white (255 250 240)
253 245 230 old lace (253 245 230)
250 240 230 linen (250 240 230)
250 235 215 antique white (250 235 215)
255 239 213 papaya whip (255 239 213)
And What I need is to cut it in lines and put them in one Array , after that i must separate each number and the rest in an string. I'm getting crazy searching functions to do that but now i can't see anyone in Javascript.
modified
End expected format will be first the next:
array[0]='255 250 250 snow (255 250 250)'
Then i wanna take it and extract each line into some vars to use them:
colour[0]=255;
colour[1]=250;
colour[2]=250;
string=snow (255 250 250);
(the vars will be reused with each line)
© Stack Overflow or respective owner