Search code examples
tcl

find and replace .\ with .@ {\/ using TCL scripts


Please help to modify below line using TCL scripts

from

top.dut.fe.stk.pma.phy.phy0.pma.dig.lane0.asic_xface.\range_counter_reg[0]

to

top.dut.fe.stk.pma.phy.phy0.pma.dig.lane0.asic_xface.@ {\/range_counter_reg[0]}.Q

tried using find and replace but didnt work


Solution

  • Using regsub -- regsub {.\\(.+)} $from {.@ {/\1}.Q}

    set from {top.dut.fe.stk.pma.phy.phy0.pma.dig.lane0.asic_xface.\range_counter_reg[0]}
    set to [regsub {.\\(.+)} $from {.@ {/\1}.Q}]
    puts $from; puts $to
    
    top.dut.fe.stk.pma.phy.phy0.pma.dig.lane0.asic_xface.\range_counter_reg[0]
    top.dut.fe.stk.pma.phy.phy0.pma.dig.lane0.asic_xface.@ {/range_counter_reg[0]}.Q