Insert Leading Zeroes

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
ScottJames
Posts: 2
Joined: Tue May 31, 2011 11:50 pm

Insert Leading Zeroes

Post by ScottJames »

Apologies if the answer to this lurks here somewhere, but a search did not turn it up.

I have a list of numbers like so:

Image

I'd like to insert a leading zero before every single digit number, so that the list appears so:

24 25 23 27
00 04 14 22
24 24 21 21
24 25 20 13
10 12 08 11
12 11 09 11

etc.

I've been banging on this with no luck for a while, so any help is greatly appreciated.
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post by ak47wong »

Enable POSIX regular expression syntax in Configure > Preferences > Editor.

Then perform this Replace operation:

Find what: _([0-9])(_|$) [replace the underscores with spaces]
Replace with: 0\1\2
[X] Regular expression
Click Replace All
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Or
Find what: _([0-9])\> [Replace the underscore with a space]
Replace with: 0\1

[X] Regular expression

Replace All
ScottJames
Posts: 2
Joined: Tue May 31, 2011 11:50 pm

Thanks

Post by ScottJames »

Excellent. Thank you very much for the speedy and dead-on help.
Post Reply