...

View Full Version : how to copy and paste from this?



qxygene
08-16-2007, 08:03 AM
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?

Fumigator
08-16-2007, 08:06 AM
You can use a regular expression....

qxygene
08-16-2007, 08:11 AM
can you explain?

mic2100
08-16-2007, 10:47 AM
Hi,

you can try this...



//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;

Fumigator
08-16-2007, 04:47 PM
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...

qxygene
08-16-2007, 05:46 PM
Warning: preg_match_all() expects at least 3 parameters, 2 given in on line 10

whizard
08-16-2007, 06:13 PM
http://uk.php.net/manual/en/function.preg-match-all.php

HTH
Dan

Inigoesdr
08-16-2007, 09:55 PM
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.

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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum