New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Apps and Games Discussion of applications and games available for Mac OS X.

how can i search and replace email addresses in a text file?


Post Reply New Thread Subscribe

 
Thread Tools
lysanderspooner

 
Member Since: May 08, 2009
Posts: 3
lysanderspooner is on a distinguished road

lysanderspooner is offline
i have a text file that i am converting into tab delimited data so that i can import it into a database. the file contains a number of email addresses which are separated by only a preceding blank space, which i want to replace with a tab. it's easy enough to find spaces and replace them with ^t (for a tab) in Word, and i could probably figure out how to search for random email addresses using wildcards, but i can't figure out how to find email addresses and then replace only the space with a tab while leaving the email address intact.

i've found several utilities that strip email addresses out of text, but they just dump them into a new file and everything else is lost.

there must be a simple way to do this. any help will be greatly appreciated.
QUOTE Thanks
technologist

 
Member Since: Mar 30, 2004
Location: USA
Posts: 4,744
technologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond reputetechnologist has a reputation beyond repute
Mac Specs: 12" Apple PowerBook G4 (1.5GHz)

technologist is offline
What you're looking for is a regular expression, and a program that supports them.

I'd suggest you start with this expression, which is basically the one described here but modified so that it instead matches a single space followed by a generic email address, instead of the address itself.
Code:
\ (?=[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)
TextWrangler, which is free, and BBEdit (from the same company) support regular expressions. Open your file, select Search > Find..., paste in the expression and check the "Use Grep" box.
QUOTE Thanks
lysanderspooner

 
Member Since: May 08, 2009
Posts: 3
lysanderspooner is on a distinguished road

lysanderspooner is offline
excellent, thanks! i have textwrangler and i will try it out.
QUOTE Thanks
lysanderspooner

 
Member Since: May 08, 2009
Posts: 3
lysanderspooner is on a distinguished road

lysanderspooner is offline
Quote:
Originally Posted by technologist View Post
What you're looking for is a regular expression, and a program that supports them.

I'd suggest you start with this expression, which is basically the one described here but modified so that it instead matches a single space followed by a generic email address, instead of the address itself.
Code:
\ (?=[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)
TextWrangler, which is free, and BBEdit (from the same company) support regular expressions. Open your file, select Search > Find..., paste in the expression and check the "Use Grep" box.
ok, that did the trick, thanks! now if only i can figure out a way to do the same thing only searching for cities... ;-)
QUOTE Thanks

Post Reply New Thread Subscribe


« Mac OS 10.0.4 issues... | Trying to run Baldur's Gate mods-WeiDu help »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
The Official "How To Transfer Your iPod or iTunes Library to Your New Mac" Thread TheCustomer99 iPod Hardware and Accessories 64 02-26-2013 02:39 PM

All times are GMT -4. The time now is 11:00 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?