moving the first occurance of a pattern to a fixed position

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
C0ppert0p
Posts: 12
Joined: Wed Aug 17, 2011 4:09 pm

moving the first occurance of a pattern to a fixed position

Post 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
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
C0ppert0p
Posts: 12
Joined: Wed Aug 17, 2011 4:09 pm

Post by C0ppert0p »

Awsome, it worked very nicely.
Thanks
Post Reply