You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Match doesn't accept a hyphen inside a character class except when it is a part of a range, e.g. [0-5] or when it is escaped [\-]. A hyphen at the beginning or the end of the character class should ideally work without escaping.
$ cd$(mktemp -d)
$ touch foo.bar
$ touch foo-bar
$ touch foobar
$ ls -l
total 0
-rw-rw-r-- 1 mohit mohit 0 Nov 25 10:05 foobar
-rw-rw-r-- 1 mohit mohit 0 Nov 25 10:05 foo-bar
-rw-rw-r-- 1 mohit mohit 0 Nov 25 10:05 foo.bar
rsc commented on the CL: "Thanks but no. While it's true that some regexp packages do accept [-] or [x-] as equivalent to [-] or [x-], it's not universal. Go is not adhering to some external spec here. We defined a specific grammar (see the doc comment on filepath.Match) and that grammar does not admit [-] nor [x-]."
Match doesn't accept a hyphen inside a character class except when it is a part of a range, e.g.
[0-5]
or when it is escaped[\-]
. A hyphen at the beginning or the end of the character class should ideally work without escaping.Test program:
Executing it results in:
The same
glob
pattern yields results in the shell:$ ls -l -- foo[.-]* -rw-rw-r-- 1 mohit mohit 0 Nov 25 10:05 foo-bar -rw-rw-r-- 1 mohit mohit 0 Nov 25 10:05 foo.bar
Similar globs appear to work in other languages too:
The text was updated successfully, but these errors were encountered: