Page 1 of 1

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

Posted: Tue Jun 05, 2012 10:03 pm
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?

Posted: Wed Jun 06, 2012 4:41 am
by MudGuard
Regexes can't do that.

You would need a script language (e.g. perl) to do that.

Posted: Wed Jun 06, 2012 7:09 pm
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.