Say I have a bunch of webforms that were submitted and I want to extract the email address of the submitter from them. I've already converted the emails to .mbox files so I can open them with Notepad++
If the line is the same in every single email, I think there should be a way I can extract all these emails in one swoop? This is the line:
Click to E-mail: joeblow@whatever.com?Subject=Website_Contact
Is there a way I can say to take everything after click to email, up to but not including that question mark and then get all those emails into a file?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would use a simple SED script to do the job. SED stands for the "Stream EDitor", a GNU freeware program. Here is the command line (written under Windows):
sed -n -e "s/Click to E-mail: \([-a-zA-Z0-9_.@]\+\).*/\1/ p" <file.mbox >>emails.txt
Input file name: file.mbox (substitute other files here, one at a time);
Output file name: emails.txt (extracted e-mails are appended to this file);
[a-zA-Z0-9_\-\.@] - regular expression that specifies which characters an e-mail address may contain.
These include a minus sign, letters "a" to "z" and "A" to "Z", underscore, period and "@". Leading minus is taken literally and is not interpreted as part of a character range specification;
\(...\) - parenthesis group characters to be extracted (presumably an e-mail address);
"Click to E-mail: " is the prefix before an e-mail, it must match exactly, character-by-character;
s/.../.../ is the "substitute" command.
Wow that is way out of my league, but thank you!
I found a site online that lets you paste a file and then it extracts email addresses, worked pretty well. But next time I'll try your command line program (as long as I know the command line!!!)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Use TextCrawler to do this.
It has a built-in regular expression for email addresses.
Just select it and choose the files to extract from and have TextCrawler do the work for you.
Say I have a bunch of webforms that were submitted and I want to extract the email address of the submitter from them. I've already converted the emails to .mbox files so I can open them with Notepad++
If the line is the same in every single email, I think there should be a way I can extract all these emails in one swoop? This is the line:
Click to E-mail: joeblow@whatever.com?Subject=Website_Contact
Is there a way I can say to take everything after click to email, up to but not including that question mark and then get all those emails into a file?
I would use a simple SED script to do the job. SED stands for the "Stream EDitor", a GNU freeware program. Here is the command line (written under Windows):
sed -n -e "s/Click to E-mail: \([-a-zA-Z0-9_.@]\+\).*/\1/ p" <file.mbox >>emails.txt
Input file name: file.mbox (substitute other files here, one at a time);
Output file name: emails.txt (extracted e-mails are appended to this file);
[a-zA-Z0-9_\-\.@] - regular expression that specifies which characters an e-mail address may contain.
These include a minus sign, letters "a" to "z" and "A" to "Z", underscore, period and "@". Leading minus is taken literally and is not interpreted as part of a character range specification;
\(...\) - parenthesis group characters to be extracted (presumably an e-mail address);
"Click to E-mail: " is the prefix before an e-mail, it must match exactly, character-by-character;
s/.../.../ is the "substitute" command.
SED Introduction and Tutorial: http://www.grymoire.com/Unix/Sed.html
Wow that is way out of my league, but thank you!
I found a site online that lets you paste a file and then it extracts email addresses, worked pretty well. But next time I'll try your command line program (as long as I know the command line!!!)
Use TextCrawler to do this.
It has a built-in regular expression for email addresses.
Just select it and choose the files to extract from and have TextCrawler do the work for you.
See the message
"Tools to find and copy regex matches in files"
By: Fool4UAnyway (fool4uanyway) - 2008-04-19 23:49
http://sourceforge.net/forum/message.php?msg_id=4915704
in the thread
"copy to clip all text matching regex pattern" (Help forum)
http://sourceforge.net/forum/forum.php?thread_id=2012623&forum_id=331754
Thanks! TextCrawler is great!!!!! Do you know of a way for it to remove duplicates when it extracts?
No, I don't. But you can use Notepad++ for that.
See, for example, the message
"delete remove duplicate line word sort length"
By: Fool4UAnyway (fool4uanyway) - 2008-07-04 10:16
http://sourceforge.net/forum/message.php?msg_id=5073042
in the thread
"Help deletin dupe words/lines and sorting" (Help forum)
http://sourceforge.net/forum/forum.php?thread_id=2011755&forum_id=482781