Click here to Skip to main content
16,005,491 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Do Arab fonts require UNICODE??? (EOM) Pin
Maximilien22-Jan-03 2:42
Maximilien22-Jan-03 2:42 
GeneralRe: Do Arab fonts require UNICODE??? (EOM) Pin
Paul M Watt22-Jan-03 6:02
mentorPaul M Watt22-Jan-03 6:02 
GeneralMessage loops... Pin
LukeV21-Jan-03 14:59
LukeV21-Jan-03 14:59 
GeneralRe: Message loops... Pin
Christian Graus21-Jan-03 15:17
protectorChristian Graus21-Jan-03 15:17 
GeneralRe: Message loops... Pin
LukeV21-Jan-03 15:29
LukeV21-Jan-03 15:29 
GeneralRe: Message loops... Pin
Christian Graus21-Jan-03 21:02
protectorChristian Graus21-Jan-03 21:02 
GeneralRe: Message loops... Pin
Michael Dunn21-Jan-03 20:28
sitebuilderMichael Dunn21-Jan-03 20:28 
GeneralEmail Address Extraction Pin
carrie21-Jan-03 12:26
carrie21-Jan-03 12:26 
Sorry, I posted this a couple of days ago then disappeared. I didn't post much info either (the problem then was me being totally dippy) so I thought I'd risk the wrath of you lads and post it again with more info, save the flogging for later please Poke tongue | ;-P

Anyway, short story is that I have to extract email addresses from a lot of files which have been exported from a database. There is no general format to these files, so its a hack & slash search to find them. The only things I have guarenteed is that there will be a space before & after the address and that the @ character will only be in the email addresses, not in any other fields. A sample of the file would be something like this but a lot bigger (roughly 2000 characters each) and they can contain more than one email address.

asd98a7098a70d98as abc-def@hotmail.com as8709-898 Dundee Geffen oiu7098

What I'm trying to do just now is write a ParseEmail(CString wholeFile) function that gets the file passed to it, and it works through picking out the email addresses. My problem is that CString isn't behaving how I would expect

while(whoIs.Find("@",0) != -1)
{
    // Found a @ character, only usually in email addresses.
    // Get the start and end of the character.
    int index = whoIs.Find("@",0);
    TRACE("@ character at position %d\n",index);

    // Find the trailing space.
    int end = whoIs.Find(' ',index);
    TRACE("end = %d\n",end);

    int pos = index-1;
    CString ch;
    ch = whoIs.GetAt(pos);
    while(ch.GetAt(pos) != ' ')
    {
        pos--;
        TRACE("ch = %s\n",ch);
    }

    CString email = whoIs.Mid(pos,end);
    TRACE("email address = %s\n",email);
    whoIs.Delete(0,end);
}


The problem after all this long windedness that the finding of the space before and after the @ doesn't work as I expect. It usually ignores spaces and other characters and returns me 50 letter email addresses Smile | :)

Does anyone have an idea of how I could improve this function so that it actually works? Cheers and sorry for the 10,000 word essay Smile | :)
GeneralRe: Email Address Extraction Pin
Larry Antram21-Jan-03 13:12
Larry Antram21-Jan-03 13:12 
GeneralRe: Email Address Extraction Pin
Christian Graus21-Jan-03 14:20
protectorChristian Graus21-Jan-03 14:20 
GeneralRe: Email Address Extraction Pin
Anonymous21-Jan-03 13:23
Anonymous21-Jan-03 13:23 
GeneralRe: Email Address Extraction Pin
Larry Antram21-Jan-03 13:21
Larry Antram21-Jan-03 13:21 
GeneralRe: Email Address Extraction Pin
bryce21-Jan-03 13:31
bryce21-Jan-03 13:31 
GeneralRe: Email Address Extraction Pin
Larry Antram21-Jan-03 13:35
Larry Antram21-Jan-03 13:35 
GeneralRe: Email Address Extraction Pin
carrie21-Jan-03 13:48
carrie21-Jan-03 13:48 
GeneralRe: Email Address Extraction Pin
Larry Antram21-Jan-03 13:52
Larry Antram21-Jan-03 13:52 
GeneralRe: Email Address Extraction Pin
carrie21-Jan-03 13:58
carrie21-Jan-03 13:58 
GeneralRe: Email Address Extraction Pin
Anonymous21-Jan-03 13:45
Anonymous21-Jan-03 13:45 
GeneralRe: Email Address Extraction Pin
Larry Antram21-Jan-03 13:47
Larry Antram21-Jan-03 13:47 
GeneralRe: Email Address Extraction Pin
Christian Graus21-Jan-03 15:19
protectorChristian Graus21-Jan-03 15:19 
GeneralRe: Email Address Extraction Pin
Andreas Saurwein21-Jan-03 13:24
Andreas Saurwein21-Jan-03 13:24 
GeneralRe: Email Address Extraction Pin
carrie21-Jan-03 13:38
carrie21-Jan-03 13:38 
Generaltoolbar resize as address in explorer. Pin
tobbemannen21-Jan-03 11:48
tobbemannen21-Jan-03 11:48 
Generalvc7 application problems in win98 Pin
Stefan Dahlin21-Jan-03 11:26
Stefan Dahlin21-Jan-03 11:26 
GeneralRe: vc7 application problems in win98 Pin
AlexO21-Jan-03 12:13
AlexO21-Jan-03 12:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.