Page 1 of 1

moving the first occurance of a pattern to a fixed position

Posted: Sat Jan 26, 2013 12:55 am
by C0ppert0p
I have a list of keywords followed by data:

Date:1/25/2013 10:37:09 AM
Event ID:902
Task Category:None
Level:Information
Keywords:Classic
User:N/A

I want to move everything following the first colon to my tab location, (40)
select ^(.*:)(.*)
replace /1/t/2

This seemed to work until I realized the split was occurring at the position of the last colon, not the first occurrence
I have also tried using (^.*:)(.*) and (.*:)(.*).
All three methods give identical results

Posted: Sat Jan 26, 2013 8:47 am
by ben_josephs
It's \1 and \t, not /1 and /t.

Repetition operators are greedy: they match as much as possible. You need to exclude colons from the match:
Find what: ([^:]*:)(.*)
Replace with: \1\t\2

Replace All

Posted: Wed Jan 30, 2013 2:40 am
by C0ppert0p
Awsome, it worked very nicely.
Thanks