Questions about builtin RegExp

Unknown W. Brackets unknown at simplemachines.org
Sun Feb 19 14:47:43 PST 2006


Andrew Fedoniouk,

What he's saying is... essentially... please take this string:

char[] some_text = "The email address Walter is posting from is 
newshound at digitalmars.com.  The headers for your message have 
<news at terrainformatica.com>, so I would assume that is your address.  My 
address can be found in this HTML: <a 
href=\"mailto:unknown at simplemachines.org\">my email</a>";

Now use strtok to output just the email addresses.  I would expect the 
output to be like this:

1: newshound at digitalmars.com
2: news at terrainformatica.com
3: unknown at simplemachines.org

How many lines will it take to grab those addresses, without using a 
regular expression?  You can use "like()" all you like, and strtok(), or 
even strpos()...

He does not mean a whitespace separated list of addresses, why would you 
need to work to parse that?  Most people would not use a regular 
expression for that, it'd be silly.

I think you're looking at this from a different angle than Walter is.

Just illustrating,
-[Unknown]


> "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