jEdit uses glob patterns similar to those in the various Unix shells to implement file name filters in the file system browser. Glob patterns resemble regular expressions somewhat, but have a much simpler syntax. The following character sequences have special meaning within a glob pattern:
?
matches any one character
*
matches any number of characters
{!
Matches
anything that does not match
glob
}glob
{
matches any one of a
,b
,c
}a
,
b
or c
[
matches
any character in the set abc
]a
,
b
or c
[^
matches
any character not in the set abc
]a
,
b
or c
[
matches
any character in the range a-z
]a
to
z
, inclusive. A leading or trailing dash
will be interpreted literally
Since we use java.util.regex
patterns to implement
globs, this means that in addition to the above, a number of
“character class metacharacters” may be used. Keep in mind,
their usefulness is limited since the regex quantifier metacharacters
(asterisk, questionmark, and curly brackets) are redefined to mean something
else in filename glob language, and the regex quantifiers are not available
in glob language.
\w
matches any alphanumeric character or
underscore
\s
matches a space or horizontal tab
\S
matches a printable
non-whitespace.
\d
matches a decimal digit
Here are some examples of glob patterns:
*
- all files.
*.java
- all files whose names end with
“.java”.
*.[ch]
- all files whose names end with
either “.c” or “.h”.
*.{c,cpp,h,hpp,cxx,hxx}
- all C or C++
files.
[^#]*
- all files whose names do not
start with “#”.
Sometimes it is desirable to use a regular expression instead of a
glob for specifying file sets. This is because regular expressions are more
powerful than globs and can provide the user with more specific filename
matching criteria. To avoid the glob-to-regex transformation, prefix your
pattern with the string (re)
, which will tell jEdit to
not translate the following pattern into a regex (since it already is one).
For example:
(re).*\.(h|c(c|pp)?)
Matches *.c, *.cpp, *.h, *.cc
If you need to match files that begin with the glob-translate-disable
prefix (re)
, you can escape it with a leading backslash
and the metacharacters will be translated into globs as before.