1 tcl>set drv 5
2 tcl>set foo "oai21_e5m_hvt"
3 tcl>regsub {_(_v\d)?e(\d+)} $foo "_ \1 e$drv" goo
4 1
5 tcl>echo $goo
6 oai21_e5m_hvt
7 tcl>echo $foo
8 oai21_e5m_hvt
9 tcl> string match $foo $goo
10 0
11 tcl>string length $foo
12 13
13 tcl>string length $goo
14 14
15 tcl>string index $goo 6
16
17 tcl>string index $foo 6
18 e
19 tcl>
Reason:
the problem is that because of the 's the \1 is being translated into hex 0x01 or the SOH char
they need to \ the \1 or \\1
the following is the right
regsub {_(_v\d)?e(\d+)} $foo "_\\1e$drv" goo
0 comments:
发表评论