Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

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>&nbsp;&nbsp;&nbsp; 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>&nbsp;</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>&gt;From: Walter Torres <WALTER@xxxxxxxxxxxxx>
<DIV></DIV>&gt;Reply-To: javascript@xxxxxxxxxx 
<DIV></DIV>&gt;To: Walter Torres <WALTER@xxxxxxxxxxxxx>
<DIV></DIV>&gt;CC: <JAVASCRIPT@xxxxxxxxxxxxxxx>, <JAVASCRIPT@xxxxxxxxxx>
<DIV></DIV>&gt;Subject: [Javascript] Q on parsing 
<DIV></DIV>&gt;Date: Tue, 23 Jul 2002 20:18:30 -0500 (CDT) 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I am 99% complete on a date format parser. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;(will post when this question is answerd!) 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;The last item is how to parse out a substring bracketed by single quotes. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;i.e.: 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I have this var... 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; var format = "EEEE, MMMM dd, yyyy ''G'' 'at' hh:mm:ss a z" ; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I can walk down this string and pull out "tokens" (same character of 1 or 
<DIV></DIV>&gt;more in length: ex: EEEE, hh, z ) 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I do it like this... 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; while ( i &lt; intFormatLen ) 
<DIV></DIV>&gt; { 
<DIV></DIV>&gt; var token = ""; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; curChar = strFormat.charAt(i); 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; while (( strFormat.charAt(i) == curChar ) &amp;&amp; ( i &lt; intFormatLen )) 
<DIV></DIV>&gt; token += strFormat.charAt(i++); 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; result += formatOptions ( token ); 
<DIV></DIV>&gt; } 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Now, a double single quote (2 in a row) needs to be grapped and passed on 
<DIV></DIV>&gt;as a single token. but not 3 in a row, the third should be part of the 
<DIV></DIV>&gt;next token. It needs to grab 2 adjacent at a time. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;If it finds one single quote, it needs to grab all characters until it 
<DIV></DIV>&gt;sees and other single quote. Yes, it needs to be able to handle an 
<DIV></DIV>&gt;embedded pair of single quotes. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;So, if I have this... 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; EEEE 'is walter''s birthday' 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;This should give me 3 tokens 
<DIV></DIV>&gt; 1) EEEE 
<DIV></DIV>&gt; 2) a SPACE 
<DIV></DIV>&gt; 3) is walter's birthday 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I can grab all but #3! :( 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I have been banging my head for 3 days on this one, I just can't see it. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Help? 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Walter 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;_______________________________________________ 
<DIV></DIV>&gt;Javascript mailing list 
<DIV></DIV>&gt;Javascript@xxxxxxxxxx 
<DIV></DIV>&gt;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>