In Tcl, I have tried to remove a substring in a string through the below expression but currently, I had to repeat the same command, again and again, to remove a different substring, from different strings so it wasn't the effective way, I wanted a better way of doing it, Is it possible to write it in a single expression
file.v
axi_p_awaddr_reg
s_ph_awlen_i_reg
l_ha_awsize_reg
s_axi_wdata_reg
set k [format {%s} [string map {{_awaddr} {}} $k]]
set k [format {%s} [string map {{_awsize} {}} $k]]
set k [format {%s} [string map {{_wdata} {}} $k]]
set k [format {%s} [string map {{_awlen} {}} $k]]
CodePudding user response:
If we assume that the requirement is really to remove multiple substrings from one string k, you can just do:
set k [string map {_awaddr {} _awsize {} _wdata {} _awlen {}} $k]