MRAB: > The regular expression changes the last sequence of digits to > "9" ("192.168.1.100" => "192.168.1.9") but the other code replaces the > last digit ("192.168.1.100" => "192.168.1.109"). Uhmm, this is a possible alternative: >>> s = " 192.168.1.100 " >>> ".".join(s.strip().split(".")[:3]) + ".9" '192.168.1.9' Bye, bearophile