|Need help lexing string literal email@example.com (1996-07-31)|
|Re: Need help lexing string literal firstname.lastname@example.org (Ruud Mulder RAF448 85606) (1996-08-01)|
|Re: Need help lexing string literal email@example.com (1996-08-04)|
|Re: Need help lexing string literal firstname.lastname@example.org (Henry Spencer) (1996-08-04)|
|From:||Henry Spencer <email@example.com>|
|Date:||4 Aug 1996 00:34:15 -0400|
|Organization:||SP Systems, Toronto|
firstname.lastname@example.org (Jay Doane) writes:
>I'm no expert with regexps, so if someone can give me some pointers,
>the correct regexp for which I'm looking, or someplace that has lots
>of different examples, where I might better educate myself, I'd be
The right way to handle this is to think of a string as an opening quote,
some "string elements", and a closing quote. A string element is normally
a single character, but can be a multi-character sequence started by a
backslash. So here's an RE for C strings, with white space inserted for
clarity, and with all backslashes standing for themselves:
" ( [^"\] | \[\abfnrtv"] | \[0-7][0-7]?[0-7]? )* "
This does assume that all backslash-newline processing has been done first,
and that the RE is being matched against a single line (that being the way
my experimental C parser, from which the above is taken, did things).
| Henry Spencer
Return to the
Search the comp.compilers archives again.