I saw a re like this:
regexp "hello\[^\\n]*06" $str
what is the \[^\\n]*
trying to match?
I saw a re like this:
regexp "hello\[^\\n]*06" $str
what is the \[^\\n]*
trying to match?
In tcl, strings grouped by double quotes (""
) undergo substitution when evaluated. As you know, tcl understands the following substitutions:
$
sign is substituted for its value.[
and ]
is treated as a statement and the first word is called as a command (function).\
) is treated as an escape sequence and substituted accordingly.Therefore, the following code:
regexp "hello\[^\\n]*06" $str
is equivalent to:
regexp {hello[^\n]*06} $str
So it's trying to match the string that contains the word "hello" and "06" without any newlines between them.