Reputation: 1179
Hi all I have a variable which is an ip address of 10.1.1.1 I want to replace the last octet in the string to b 0
I have tried a few things from string replace and regsub but I have not really got anything that worked for me. can someone suggest how to change a string of 10.1.1.1 to 10.1.1.0 ?
I appreciate any help.
Upvotes: 1
Views: 620
Reputation: 247082
% set ip 10.1.1.1
10.1.1.1
% set new [join [lreplace [split $ip .] end end 0] .]
10.1.1.0
Upvotes: 2
Reputation: 185801
What did you try? regsub
can do this pretty trivially.
regsub {\d+$} $input 0
Upvotes: 1