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 23:17:09 -0700
Toms last message got me thinking, and this is what I came up with. (see
below)
It works, but it is ugly as sin.
Anyone fell like 'improving' it?
Walter
========================
// Loop through the format string
while ( i < intFormatLen )
{
// clear token
token = "";
// Retrieve individual character
curChar = strFormat.charAt(i);
// Build the format tokens
while (( strFormat.charAt(i) == curChar ) && ( i < intFormatLen ))
{
// Add current character to token string
token += strFormat.charAt(i);
// Increment to retrieve next char
i++;
// See if we have a single qoute with its mate next to it
if ( ( token == "'" ) && ( strFormat.charAt(i) != "'" ) )
{
// clear token
token = "";
// Loop through format string until we see another single quote
while (( strFormat.charAt(i) != "'" ) && ( i < intFormatLen ))
{
// Pull out character
cChr = strFormat.charAt(i);
// Add it to to token string if it is not a single quote
token += ( cChr != "'" ) ? cChr : '';
// Increment to retrieve next char
i++;
}
// Increment to retrieve next char
i++;
}
}
// Look at the individual token, one or more characters in length
// and pull corosponding value from format collection,
// otherwise just pass the token through
result += formatOptions ( token );
}
return result;
Thanks
- Follow-Ups:
- [Javascript] Q on date operations
- From: Walter Torres
- [Javascript] Q on date operations
- References:
- [Javascript] Q on parsing
- From: Walter Torres
- [Javascript] Q on parsing
- Prev by Date: [Javascript] Q on parsing
- Next by Date: [Javascript] Q on date operations
- Previous by thread: [Javascript] Q on parsing
- Next by thread: [Javascript] Q on date operations
- Index(es):