Kiwi
Kiwi

Reputation: 2773

Regular expression in sublime

I have this thing where I usual have something like (but not always)

- 30 30: 0  4 58 E

and that must be

- 30 30
: 0  4 58 E

or, in another case

- 32 32
: 0  2 63 All 

must remain as it is

- 32 32
: 0  2 63 All 

So any : must always be on the next line. Is there an regex for fixing every case of this (so that it only does this when the : isn't already on a new line?

I'm using Sublime text as editor

Upvotes: 0

Views: 179

Answers (1)

Bergi
Bergi

Reputation: 665316

when the ":" is already on a new line, it can't be given another one

Then you want to use a negative lookbehind:

(?<!\n):

Replace that with \n:.

If lookbehind is not supported, you also could match colons that follow digits: Replace (\d): with $1\n: - using a capturing group.

Upvotes: 3

Related Questions