Extracting Email Addresses Only

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
bad959fl
Posts: 21
Joined: Wed Jun 15, 2005 11:32 pm

Extracting Email Addresses Only

Post by bad959fl »

I just extracted over 10K user accounts from our forum and it ended up in this format:

username user@email.com

How can I extract only the email address from this line? I tried bookmarking "@", but it picked up the username also. Any thoughts?
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Search for: ^.+[[:blank:]]
Replace with: nothing


Using POSIX and RegEx on

Always have a backup available.
Hope this was helpful.............good luck,
Bob
bad959fl
Posts: 21
Joined: Wed Jun 15, 2005 11:32 pm

Post by bad959fl »

Hi Bob,

Thanks but it seemed to remove all the lines but one. The text file is listed with over 10K lines like this:

-------------------------------------
username1 email@email1.com
username2 email@email2.com
username3 email@email3.com
-------------------------------------

I want it to end up like this:

-------------------------------------
email@email1.com
email@email2.com
email@email3.com
-------------------------------------

Thanks!
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Just took your last example.
I end up with this:

-------------------------------------
email@email1.com
email@email2.com
email@email3.com
-------------------------------------

Looks the same to me. What am I not seeing?
Hope this was helpful.............good luck,
Bob
bad959fl
Posts: 21
Joined: Wed Jun 15, 2005 11:32 pm

Post by bad959fl »

Turned on POSIX and now it removes everything (reg exp: on). Here are my setting:

Find What: ^.+[[:blank:]]
Replace with: nothing
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

.+ is greedy, so if there is a blank at the end of the line, it removes all.

use
^[^[:blank:]]+[[:blank:]]
instead, i.e. search for as many non-blanks as possible at the beginning of the line plus one blank after that.


If your user names can contain blanks, it gets more complicated:
^.*[[:blank:]]([^[:blank:]]+@)
replace by \1
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Thanks MudGuard for pointing out the invisible spaces at the ends of the line.

I should have thought of that myself even though there was no mention of it in the samples.
Hope this was helpful.............good luck,
Bob
bad959fl
Posts: 21
Joined: Wed Jun 15, 2005 11:32 pm

Post by bad959fl »

Great, worked perfectly! Thanks guys :)
bad959fl
Posts: 21
Joined: Wed Jun 15, 2005 11:32 pm

Post by bad959fl »

Ah, wrote too soon. It seems like there are many entries which still left the username in the line with a space after it. Is there a way to remove all extra spaces only at the end of the line? This way, I can weed them out and do a search for the username spaces after that.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find what: _+$ [Replace the underscore with a space]
Replace with: [nothing]

[X] Regular expression
Post Reply