[Fixed]advanced replacement

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
bestycame
Posts: 2
Joined: Tue Sep 16, 2008 2:48 am

[Fixed]advanced replacement

Post by bestycame »

Hi All,
i'm having some trouble to find how i could instruct Textpad to make a couple of replacements in a file that i have got.
for the moment, i have a big file (180 000 lines) that is actually a list of tags followed by some information.

it looks like this

Code: Select all

NAME Bestycame
ID 32553
HO1 abcdef' MNOPQ xy QWERTY
and what i would like to do is to replace every line that begin by 'HOP' then a couple of lowercase (and sometimes the caracter ' and a space eg: ab; ab'; ab cd) to be splitted into two lines, one with a new tag and the first set of lowercase, and the second one with the old tag and the rest of the data.

to have something that looks like this instead:

Code: Select all

NAME Bestycame
ID 32553
HO0 abcdef'
HO1 MNOPQ xy QWERTY
any idea how i could do that?
thanks a lot!
Last edited by bestycame on Tue Sep 16, 2008 10:50 pm, edited 1 time in total.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Replace each underscore with a space in:

Find what: ^(HO[0-9])_([a-z'_]+)_(.*)
Replace with: HO0_\2\n\1_\3

[X] Match case
[X] Regular expression

Replace All
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
bestycame
Posts: 2
Joined: Tue Sep 16, 2008 2:48 am

Post by bestycame »

Oh man! it works that's great!
thanks a million for your help!

damn, Textpad is so powerfull!
Post Reply