Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to copy and paste from this?

    i have an old sql file from phpbb lines are like this;

    INSERT INTO `phpbb_users` VALUES (702, 1, 'Harley Beau', '827ccb0eea8a706c4c34a16891f84e7b', 0, 0, 0, 1185428727, 0, 0, -12.00, 1, 'albanian', 'D M d, Y g:i a', 0, 0, 0, 0, 0, NULL, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, '', 0, '57b16b7c49@todoscol.org', '', 'http://www.seamcat.org/xwiki/bin/download/XWiki/NoraMilton/amateurpics.html', 'Somethere', '', '', '', '', '', '', '', '', NULL);

    INSERT INTO `phpbb_users` VALUES (703, 1, 'Fertassal', '91f004cf5aa5e8f7580b3a8001b17acd', 0, 0, 0, 1185473363, 0, 0, -12.00, 1, 'albanian', 'D M d, Y g:i a', 0, 0, 0, 0, 0, NULL, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, '', 0, 'fertassa@mail.ru', '135664', 'http://www.mulka.ru', 'Russia', '', '', '', '', '', 'news and links', 'download MP3', '', NULL);

    i would like to create a new text document and copy paste only email addresses from this sql file..


    Text Doc. will be like this;

    57b16b7c49@todoscol.org
    fertassa@mail.ru

    any idea?

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You can use a regular expression....

  • #3
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can you explain?

  • #4
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    Hi,

    you can try this...

    PHP Code:
    //read the text into a variable called $text and use the following code to extract all email addresses

    $regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
    $emailAddress = array();

    $emailAddress preg_match_all($regexp$text);

    foreach(
    $emailAddress as $label => $value):

        echo 
    "$value <br>";

    endforeach; 

  • #5
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You could also just create a table and insert all that data into the table and then run a query to extract the email addresses and write them to a file. If you're having trouble getting the regex to work...

  • #6
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Warning: preg_match_all() expects at least 3 parameters, 2 given in on line 10

  • #7
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #8
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Change the line to this: $return = preg_match_all($regexp, $text, $emailAddress);. You don't even need the $return really since there's no error checking.
    Quote Originally Posted by Fumigator View Post
    You could also just create a table and insert all that data into the table and then run a query to extract the email addresses and write them to a file. If you're having trouble getting the regex to work...
    This is what I would suggest; it should be a lot easier than trying to extract the addresses with regex. Especially if you have a lot of rows.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •