moving words to end of line

General questions about using TextPad

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

Post Reply
ilovetextpad
Posts: 13
Joined: Thu Sep 29, 2005 6:53 am

moving words to end of line

Post by ilovetextpad »

ive got several lines that all start with the same word, for example:

Noun: stratum (strata)
1. One of several parallel...

Noun: culvert
1. A transverse and totally... etc.

what i want to do is move the first word(noun in this case) to the end of the first line, placing it behind "(strata)" in the first example and behind "culvert" in the second. is that even possible with regular expressions or should i look around for other solutions?
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Are you interested only in lines beginning with the text Noun: ? Then this might do it:
Find what: ^Noun: (.*)
Replace with: \1 Noun

[X] Regular expression
Or are you interested in all lines beginning with a word followed by a colon? Then this might be a good starting point:
Find what: ^([a-z]+): (.*)
Replace with: \2 \1

[X] Regular expression
The parentheses in the regular expressions capture and number subexpressions of the matched text, and the back-slashed numbers in the replacement expressions are place-holders for those captured and numbered subexpressions. So text can be reordered by the judicious capture of subexpressions and ordering of their place-holders.

These assume you are using Posix regular expression syntax:
Configuration | Preferences | Editor

[X] Use POSIX regular expression syntax
ilovetextpad
Posts: 13
Joined: Thu Sep 29, 2005 6:53 am

Post by ilovetextpad »

its not just the word noun, but they are all followed by a colon. i just tried the second example you posted and it worked like a charm. thanks ben, and thanks for the explanation. it made things a lot clearer.
Post Reply