Results 1 to 4 of 4
  1. #1


    Member Since
    May 08, 2009
    Posts
    3
    how can i search and replace email addresses in a text file?
    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.

  2. #2


    Member Since
    Mar 30, 2004
    Location
    USA
    Posts
    4,744
    Specs:
    12" Apple PowerBook G4 (1.5GHz)
    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.

  3. #3


    Member Since
    May 08, 2009
    Posts
    3
    excellent, thanks! i have textwrangler and i will try it out.

  4. #4


    Member Since
    May 08, 2009
    Posts
    3
    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... ;-)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. deleting FB email addresses
    By curtcloninger in forum OS X - Operating System
    Replies: 2
    Last Post: 02-18-2015, 07:02 PM
  2. File search and replace
    By dartiss in forum OS X - Apps and Games
    Replies: 2
    Last Post: 11-05-2012, 11:47 AM
  3. Email addresses
    By TJohnB in forum Switcher Hangout
    Replies: 3
    Last Post: 06-03-2012, 01:44 AM
  4. Deleting Email addresses
    By eaglesclaw121 in forum OS X - Operating System
    Replies: 0
    Last Post: 09-15-2011, 06:24 PM
  5. search for lines of text in a huge file
    By jakeroberts in forum OS X - Apps and Games
    Replies: 14
    Last Post: 06-10-2007, 10:21 AM

Posting Permissions

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