Questions about builtin RegExp
Andrew Fedoniouk
news at terrainformatica.com
Sun Feb 19 11:05:55 PST 2006
"Walter Bright" <newshound at digitalmars.com> wrote in message
news:dt9ho8$20e4$3 at digitaldaemon.com...
>>> Writing a real lexer takes a lot of effort. That's why people invented
>>> regex, it'll handle most jobs without having to write a lexer. C's
>>> strtok() is embarassingly inadequate.
>>
>> Why?
>
> I'd like to see strtok() parse an email address out of a body of text.
>
I don't really understand "parse an email address out of a body of text."
Do you mean something like this:
char* pw = text;
url u;
forever
{
pw = strtok( pw, " \t\n\r" ); if( !pw ) return;
if( !u.parse(pw) ) continue;
if( u.protocol() == url::MAILTO )
//found - do something here
;
};
?
Andrew.
More information about the Digitalmars-d
mailing list