regex with tcl and $ in variable value -


I need help for this regex to tcl. I want to figure out $ character but this is not flagging. Any ideas?

  set cell {ABC_ONE_123_ $ 12345 $ wc_PIE_IN_SKY} string mail $$ cell  

String match and globe pattern

string match matches a match against the globe pattern Besides, not a regular expression, it will try to match the entire string. The globe pattern does not match the $ because the string is more than just a dollar sign, even though * $ * does, because it is "zero or more characters, one dollar Symbol, and zero or more characters ". Because $ is specially treated by TCL shell, you have to cite it properly. For example:

 % string match {* $ *} $ cell 1% string match * \ $ * $ cell1  

Regular Expression

If you really want to make a regular expression instead of a globe pattern match, use the regexp command in this case, you have a) Should protect $ from the usual TCL interpretation such as string match , and b) because it is special for regular expressions, Reggae should be interpreted by interpretation

Here is an example:

 % regexp {$ $} $ cell 1% regexp \ $ $ cell 1  

Comments