Would like to add 1 digit to a group...

General questions about using TextPad

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

Post Reply
domingo1979
Posts: 1
Joined: Tue Jun 05, 2012 9:58 pm

Would like to add 1 digit to a group...

Post by domingo1979 »

Hello all. I'm not sure if this is possible in textpad but I would like to know if your expertise could assist in the following....

I am trying to replace the third octet in a given IP address to be followed by the next available integer.

For example.

find
10.15.236.3

replace with
10.15.237.3

I have a series of IP addresses in a doc with a lot of other text that needs to stay in place. The IP addresses are unique in the doc so I can search strictly for an IP address and have it replaced with the value I am looking for.


I have tried grouping with textpad but unfortunately I'm not too savvy at regex.

I was thinking along the lines of something like this...

find...
([0-9].*)\.([0-9].*)\.([0-9].*)\.([0-9])

keep...
$1$2$4 but replace $3 with the next subsequent number.

Is there anyway to do this?
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Regexes can't do that.

You would need a script language (e.g. perl) to do that.
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Post by kengrubb »

If you had a list of IP addresses without any breaks, then it could be done with REGEX.

10.15.236.3
10.15.237.3
10.15.238.3
10.15.239.3
10.15.240.3
10.15.241.3
10.15.242.3

But, if there were any interruptions, it would break.
(2[Bb]|[^2].|.[^Bb])

That is the question.
Post Reply