Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15644
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Gene Wirchenko <genew@ocis.net> |
| Newsgroups | comp.lang.javascript |
| Subject | String Processing in JavaScript |
| Date | Fri, 31 Aug 2012 15:56:27 -0700 |
| Organization | A noiseless patient Spider |
| Lines | 30 |
| Message-ID | <rgf248la5ap1dusauc9ek39jasff47mht4@4ax.com> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| Injection-Info | mx04.eternal-september.org; posting-host="c0a6a1dc41fc92eb7000e57afbd16211"; logging-data="26502"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18t+70xdANLE2LnvqC+qvrkY381Phv9oNM=" |
| X-Newsreader | Forte Agent 4.2/32.1118 |
| Cancel-Lock | sha1:+5i4DGQq1/5iu7s1M8tjcSvlEV0= |
| Xref | csiph.com comp.lang.javascript:15644 |
Show key headers only | View raw
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?)
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 — 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