Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Q on parsing
- From: javascript@xxxxxxxxxx (Walter Torres)
- Subject: [Javascript] Q on parsing
- Date: Tue, 23 Jul 2002 20:20:30 -0700
As an aside, I am trying to keep this as down compatible as possible. This means no RegExp. walter > -----Original Message----- > From: javascript-admin@xxxxxxxxxx > [mailto:javascript-admin@xxxxxxxxxx]On > Behalf Of Walter Torres > Sent: Tuesday, July 23, 2002 6:19 PM > To: Walter Torres > Cc: javascript@xxxxxxxxxxxxxxx; javascript@xxxxxxxxxx > Subject: [Javascript] Q on parsing > > > I am 99% complete on a date format parser. > > (will post when this question is answerd!) > > The last item is how to parse out a substring bracketed by > single quotes. > > i.e.: > > I have this var... > > var format = "EEEE, MMMM dd, yyyy ''G'' 'at' hh:mm:ss a z" ; > > I can walk down this string and pull out "tokens" (same > character of 1 or > more in length: ex: EEEE, hh, z ) > > I do it like this... > > while ( i < intFormatLen ) > { > var token = ""; > > curChar = strFormat.charAt(i); > > while (( strFormat.charAt(i) == curChar ) && ( i < > intFormatLen )) > token += strFormat.charAt(i++); > > result += formatOptions ( token ); > } > > > Now, a double single quote (2 in a row) needs to be grapped > and passed on > as a single token. but not 3 in a row, the third should be part of the > next token. It needs to grab 2 adjacent at a time. > > If it finds one single quote, it needs to grab all characters until it > sees and other single quote. Yes, it needs to be able to handle an > embedded pair of single quotes. > > So, if I have this... > > EEEE 'is walter''s birthday' > > This should give me 3 tokens > 1) EEEE > 2) a SPACE > 3) is walter's birthday > > I can grab all but #3! :( > > I have been banging my head for 3 days on this one, I just > can't see it. > > Help? > > Walter > > _______________________________________________ > Javascript mailing list > Javascript@xxxxxxxxxx > https://lists.LaTech.edu/mailman/listinfo/javascript
- References:
- [Javascript] Q on parsing
- From: Walter Torres
- [Javascript] Q on parsing
- Prev by Date: [Javascript] Q on parsing
- Next by Date: [Javascript] Trapping "File not Found"
- Previous by thread: [Javascript] Q on parsing
- Next by thread: [Javascript] Q on parsing
- Index(es):