string - two asterisk sttring match in TCL -
help me decide 1 problem in tcl. using macros want find string, contains 2 asterisk (**). tried used following commands:
string match \*\* string_name but doesn't work. can explain me made mistake , how correctly?
thanks in advance!
what passing interpreter string match ** string_name. need pass actual backslashes interpreter understand 2 escaped asterisks, , need add couple more backslashes:
string match \\*\\* $s or use braces:
string match {\*\*} $s note above match only if $s contains 2 asterisks, , nothing else. allow before , after asterisks, can use more asterisks...
string match {*\*\**} $s there few other ways check if string has double asterisks, can instance use string first (and since 1 not support expressions, can away without having escape anything):
string first ** $s if greater -1, ** present in $s.
or if happen know regular expressions:
regexp -- {\*\*} $s those common think.
Comments
Post a Comment