Regular Expression - Capture and Replace Select Sequences

Posted by Chad on Stack Overflow See other posts from Stack Overflow or by Chad
Published on 2010-05-28T05:50:37Z Indexed on 2010/05/28 5:51 UTC
Read the original article Hit count: 190

Filed under:
|

Take the following file...

ABCD,1234,http://example.com/mpe.exthttp://example/xyz.ext EFGH,5678,http://example.com/wer.exthttp://example/ljn.ext

Note that "ext" is a constant file extension throughout the file.

I am looking for an expression to turn that file into something like this...

ABCD,1234,http://example.com/mpe.ext ABCD,1234,http://example/xyz.ext EFGH,5678,http://example.com/wer.ext EFGH,5678,http://example/ljn.ext

In a nutshell I need to capture everything up to the urls. Then I need to capture each URL and put them on their own line with the leading capture.

I am working with sed to do this and I cannot figure out how to make it work correctly. Any ideas?

© Stack Overflow or respective owner

Related posts about regex

Related posts about sed