'tcl expression to rename multiple strings in a file

In a file, I have multiple strings,

valid_packet,
rst_int_reg,
write_enb,
enb_read,
state_lfd, ...

I have to rename the strings in the below format

validpacket
lfd_state
read_enb

I have written an expression to rename a few of the strings

set signals " valid_packet, rst_int_reg, write_enb, read_enb, state_lfd, ..."

set signals [regsub "valid_packet" $signals "validpacket"]
set signals [regsub "enb_read" $signals "read_enb"]
set signals [regsub "state_lfd" $signals "lfd_state"]
puts $signals 

For each string, I had to write the same expression, so is there any optimized way, because if I have to rename many strings in a file, I need to repeat the same expression.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source