How to use a variable in regexp [removed]TCL/Expect)

前端 未结 1 1854
孤独总比滥情好
孤独总比滥情好 2021-01-06 03:15

I\'m trying to figure out how to use a string in a regexp match. I have been searching on google for an hour, figured i would just ask the experts.

This works:

相关标签:
1条回答
  • 2021-01-06 03:54

    Right. You have 2 options: enclose the pattern with " , but then you have to protect \ from being parsed by Tcl instead of the regxp. Or you can use regexp -nocase [subst -nocommands -nobackslashes {something here:\s+$MYSTR}].

    PS: put always {} around the expression:

    if {[regexp -nocase [subst -nocommands -nobackslashes {something here:\s+$MYSTR}]} then {
    ...
    }
    
    0 讨论(0)
提交回复
热议问题