Reputation: 2256
While using Tcl, as mentioned in the documentation here, shouldn't the following code,
string match h* match
, return 1 for the matched h character in "match" instead of what it actually returns , that is, 0 ?
Upvotes: 0
Views: 747
Reputation: 16428
In the same page itself you have the following content,
# Matches
string match f* foo
# Matches
string match f?? foo
# Doesn't match
string match f foo
The match is applied as if a whole word, not like string contains that particular word.
With string match h* match
, it will try to match a pattern whose first letter is h
and further zero or more occurrence of any string of characters, which is not true for word match
.
Instead, you can rely on regexp
for what you expect to happen.
# Matches, will return 1
regexp h* match
Upvotes: 2