Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15648
| From | Jim T. <x@y.z> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: String Processing in JavaScript |
| Date | 2012-08-31 22:30 -0400 |
| Message-ID | <6os248lttein62omugahl5avvlpb18o8o2@4ax.com> (permalink) |
| References | <rgf248la5ap1dusauc9ek39jasff47mht4@4ax.com> |
On Fri, 31 Aug 2012 15:56:27 -0700, Gene Wirchenko <genew@ocis.net> wrote: >Dear JavaScripters: > > I will be passing back long result strings to my Web pages. These >strings have to be parsed into error codes and form field contents. >What I am working with looks like > <fieldname>:<value length>:<value>\n >The value is encodeURIComponent()ed. > > The way that I am doing it right now for the first two values on >a line is to look for a colon (with String.indexOf(), grab what is in >front of the colon, and then delete up to the colon from the string. >(I then grab the indicated number of characters and decode for the >field value and ensure the following character is "\n" and delete up >to the "\n".) > > I have to delete because of how String.indexOf() works. It does >not have a string start point. Am I better off: > 1) doing what I am doing, > 2) keeping track of where I am in the string and have each >.indexOf() operate on a .substr() of the string, or > 3) using some other function I know not of? (What?) Perhaps String.split() ? > I suppose that another way of doing it would be a regex, but they >have poor error handling. I expect to make a lot of errors while >working this all out, and I prefer to get good error messages rather >than just a parse failure. > >Sincerely, > >Gene Wirchenko
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
String Processing in JavaScript Gene Wirchenko <genew@ocis.net> - 2012-08-31 15:56 -0700
Re: String Processing in JavaScript Mike Winter <usenet@michael-winter.me.invalid> - 2012-09-01 02:30 +0100
Re: String Processing in JavaScript Gene Wirchenko <genew@ocis.net> - 2012-09-02 17:56 -0700
Re: String Processing in JavaScript Jim T. <x@y.z> - 2012-08-31 22:30 -0400
Re: String Processing in JavaScript "Mel Smith" <med_cutout_syntel@aol.com> - 2012-08-31 21:47 -0600
Re: String Processing in JavaScript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-09-01 08:51 +0000
Re: String Processing in JavaScript "Mel Smith" <med_cutout_syntel@aol.com> - 2012-09-01 08:38 -0600
Re: String Processing in JavaScript Gene Wirchenko <genew@ocis.net> - 2012-09-02 18:04 -0700
Re: String Processing in JavaScript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-09-03 16:30 +0000
Re: String Processing in JavaScript Mike Winter <usenet@michael-winter.me.invalid> - 2012-09-03 21:23 +0100
Re: String Processing in JavaScript Gene Wirchenko <genew@ocis.net> - 2012-09-03 14:26 -0700
Re: String Processing in JavaScript Stefan Weiss <krewecherl@gmail.com> - 2012-09-03 19:29 +0200
Re: String Processing in JavaScript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-03 21:45 +0200
Re: String Processing in JavaScript Gene Wirchenko <genew@ocis.net> - 2012-09-03 14:27 -0700
Re: String Processing in JavaScript Stefan Weiss <krewecherl@gmail.com> - 2012-09-04 00:48 +0200
Re: String Processing in JavaScript Gene Wirchenko <genew@ocis.net> - 2012-09-03 17:20 -0700
Re: String Processing in JavaScript Tim Streater <timstreater@greenbee.net> - 2012-09-04 10:06 +0100
Re: String Processing in JavaScript Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2012-09-04 20:02 +1000
Re: String Processing in JavaScript Gene Wirchenko <genew@ocis.net> - 2012-09-04 08:47 -0700
csiph-web