Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Q on parsing
- From: javascript@xxxxxxxxxx (Chris Berry)
- Subject: [Javascript] Q on parsing
- Date: Tue, 23 Jul 2002 18:34:27 -0700
<html><div style='background-color:'><DIV>
<P> Just a quick thought, don't you have to use the escape character \ for that?<BR><BR>Chris Berry </P></DIV>compjma@xxxxxxxxxxx
<DIV></DIV>
<DIV></DIV>Systems Administrator
<DIV></DIV>
<DIV></DIV>JM Associates
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV> </DIV>
<DIV></DIV>
<DIV><EM>"Ask me for the impossible and I'll do it immediately, miracles take a little longer."</EM></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>>From: Walter Torres <WALTER@xxxxxxxxxxxxx>
<DIV></DIV>>Reply-To: javascript@xxxxxxxxxx
<DIV></DIV>>To: Walter Torres <WALTER@xxxxxxxxxxxxx>
<DIV></DIV>>CC: <JAVASCRIPT@xxxxxxxxxxxxxxx>, <JAVASCRIPT@xxxxxxxxxx>
<DIV></DIV>>Subject: [Javascript] Q on parsing
<DIV></DIV>>Date: Tue, 23 Jul 2002 20:18:30 -0500 (CDT)
<DIV></DIV>>
<DIV></DIV>>I am 99% complete on a date format parser.
<DIV></DIV>>
<DIV></DIV>>(will post when this question is answerd!)
<DIV></DIV>>
<DIV></DIV>>The last item is how to parse out a substring bracketed by single quotes.
<DIV></DIV>>
<DIV></DIV>>i.e.:
<DIV></DIV>>
<DIV></DIV>>I have this var...
<DIV></DIV>>
<DIV></DIV>> var format = "EEEE, MMMM dd, yyyy ''G'' 'at' hh:mm:ss a z" ;
<DIV></DIV>>
<DIV></DIV>>I can walk down this string and pull out "tokens" (same character of 1 or
<DIV></DIV>>more in length: ex: EEEE, hh, z )
<DIV></DIV>>
<DIV></DIV>>I do it like this...
<DIV></DIV>>
<DIV></DIV>> while ( i < intFormatLen )
<DIV></DIV>> {
<DIV></DIV>> var token = "";
<DIV></DIV>>
<DIV></DIV>> curChar = strFormat.charAt(i);
<DIV></DIV>>
<DIV></DIV>> while (( strFormat.charAt(i) == curChar ) && ( i < intFormatLen ))
<DIV></DIV>> token += strFormat.charAt(i++);
<DIV></DIV>>
<DIV></DIV>> result += formatOptions ( token );
<DIV></DIV>> }
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>Now, a double single quote (2 in a row) needs to be grapped and passed on
<DIV></DIV>>as a single token. but not 3 in a row, the third should be part of the
<DIV></DIV>>next token. It needs to grab 2 adjacent at a time.
<DIV></DIV>>
<DIV></DIV>>If it finds one single quote, it needs to grab all characters until it
<DIV></DIV>>sees and other single quote. Yes, it needs to be able to handle an
<DIV></DIV>>embedded pair of single quotes.
<DIV></DIV>>
<DIV></DIV>>So, if I have this...
<DIV></DIV>>
<DIV></DIV>> EEEE 'is walter''s birthday'
<DIV></DIV>>
<DIV></DIV>>This should give me 3 tokens
<DIV></DIV>> 1) EEEE
<DIV></DIV>> 2) a SPACE
<DIV></DIV>> 3) is walter's birthday
<DIV></DIV>>
<DIV></DIV>>I can grab all but #3! :(
<DIV></DIV>>
<DIV></DIV>>I have been banging my head for 3 days on this one, I just can't see it.
<DIV></DIV>>
<DIV></DIV>>Help?
<DIV></DIV>>
<DIV></DIV>>Walter
<DIV></DIV>>
<DIV></DIV>>_______________________________________________
<DIV></DIV>>Javascript mailing list
<DIV></DIV>>Javascript@xxxxxxxxxx
<DIV></DIV>>https://lists.LaTech.edu/mailman/listinfo/javascript
<DIV></DIV></div><br clear=all><hr>MSN Photos is the easiest way to share and print your photos: <a href='http://g.msn.com/1HM1ENUS/c156??PI=44364'>Click Here</a><br></html>
- Follow-Ups:
- [Javascript] Q on parsing
- From: Walter Torres
- [Javascript] Q on parsing
- Prev by Date: [Javascript] Q on parsing
- Next by Date: [Javascript] Q on parsing
- Previous by thread: [Javascript] Q on parsing
- Next by thread: [Javascript] Q on parsing
- Index(es):