TextPad macro question

General questions about using TextPad

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

Post Reply
Mathias
Posts: 1
Joined: Tue Jan 08, 2013 3:16 pm

TextPad macro question

Post by Mathias »

I have a large file that i want to edit using a macro. The data in rows needs to be changed so that it is in the right position. The problem is that not all the data in all rows have the same length so if i create a macro for say row 1 and try to apply this for all rows it won't work.

eg.

row1: Mathias Andersson 201301081555 GHT
row2: Niklas Andersson 201301091555 FGTGJJT

the result i need:

Name on position 1-20, Date&time on position 30-45 and school on position 60-85.

and so on...

Any ideas on how to make this work?
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post by ak47wong »

You can insert tabs to align the data and then convert the tabs to spaces.

Step 1
You could record a macro to insert a tab between the name and date and between the date and school. Even though the data are different lengths, you should be able to use Ctrl+Left and Ctrl+Right to jump between words. Or you can search for the beginning of the date while recording the macro.

Alternatively, you can do a single find-and-replace operation using regular expressions.

First, enable POSIX regular expression syntax in Configure > Preferences > Editor. Then do a Replace as follows:

Find what: (.*)_([0-9]{12})_(.*) [replace the underscores with spaces]
Replace with: \1\t\2\t\3

Select Regular expression and click Replace All.

Step 2
  1. Click View > Document Properties.
  2. On the Tabulation tab, select Convert existing tabs to spaces when saving files.
  3. Under Tab stops, enter 30 and click Set.
  4. Enter 60 and click Set.
Step 3
Save the file.
Post Reply