Advanced regular expressions let us write the "2 hex digits" pattern a bit more cleanly: regsub -all {%([[:xdigit:]]{2})} $url \ {[format %c 0x\1]} url The resulting string is passed to subst to get the format commands substi- tuted: set url [subst $url] For example, if ...