There seems to be something weird about strmatch, and I just can't find out what. I'm trying to match file names, and I stumbled on a problem that reduces to this:
Why is the last one 0? I suspected some kind of special use of backslash (like in C to quote characters), but Stata doesn't do that usually, and anyway di strmatch("a\b","*\\*") also returns 0. And I found nothing about backslash in strmatch in the documentation.
There is the same problem with:
There is a workaround:
And here the backslash is doubled because it's the quoting character for regular expressions (e.g., to match the character "*" use "\*").
Has anyone an explanation for this behaviour of strmatch?
Code:
. di strmatch("a/*","*/*") 1 . di strmatch("a/b","*/*") 1 . di strmatch("a\*","*\*") 1 . di strmatch("a\b","*\*") 0
There is the same problem with:
Code:
. di strmatch("a\?","*\?") 1 . di strmatch("a\b","*\?") 0
Code:
. di regexm("a\b",".*\\.*") 1
Has anyone an explanation for this behaviour of strmatch?
Comment