Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm completely new to RegEx and could really use some help with my dilemma. I have a large text file of IP addresses and corresponding hosts:

157.55.33.47 msnbot-157-55-33-47.search.msn.com
157.56.93.62 msnbot-157-56-93-62.search.msn.com
etc...

I need a find and replace algorithm that appends to the beginning and end of each line and replaces the delimiter, which in this case is just a space.

e.g. the output after running the regex should be:

'text1' 157.55.33.47 'text2' msnbot-157-55-33-47.search.msn.com 'text3'
'text1' 157.56.93.62 'text2' msnbot-157-56-93-62.search.msn.com 'text3'
share|improve this question

Find ^([A-Za-z0-9.-]+) ([A-Za-z0-9.-]+)$

Replace 'Text 1' \1 'Text 2' \2 'Text 3'

Each bracket pair creates a Group, which is then put in the replace function in order with the \1, \2 sections.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .