/www/tags/NOV_07_2009/htdocs/users-guide/globs.html
HTML | 36 lines | 36 code | 0 blank | 0 comment | 0 complexity | f37ab21d018dd9a6264ca8ebee4a518f MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Appendix D. Glob Patterns</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="jEdit 4.3 User's Guide"><link rel="up" href="using-jedit-part.html" title="Part I. Using jEdit"><link rel="prev" href="history.html" title="Appendix C. History Text Fields"><link rel="next" href="regexps.html" title="Appendix E. Regular Expressions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix D. Glob Patterns</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="history.html">Prev</a> </td><th width="60%" align="center">Part I. Using jEdit</th><td width="20%" align="right"> <a accesskey="n" href="regexps.html">Next</a></td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="globs"></a>Appendix D. Glob Patterns</h2></div></div></div><p>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:</p><div class="itemizedlist"><ul type="disc"><li><p><code class="literal">?</code> matches any one character</p></li><li><p><code class="literal">*</code> matches any number of characters</p></li><li><p><code class="literal">{!<em class="replaceable"><code>glob</code></em>}</code> Matches
- anything that does <span class="emphasis"><em>not</em></span> match
- <em class="replaceable"><code>glob</code></em></p></li><li><p><code class="literal">{<em class="replaceable"><code>a</code></em>,<em class="replaceable"><code>b</code></em>,<em class="replaceable"><code>c</code></em>}</code>
- matches any one of <em class="replaceable"><code>a</code></em>,
- <em class="replaceable"><code>b</code></em> or <em class="replaceable"><code>c</code></em></p></li><li><p><code class="literal">[<em class="replaceable"><code>abc</code></em>]</code> matches
- any character in the set <em class="replaceable"><code>a</code></em>,
- <em class="replaceable"><code>b</code></em> or <em class="replaceable"><code>c</code></em></p></li><li><p><code class="literal">[^<em class="replaceable"><code>abc</code></em>]</code> matches
- any character not in the set <em class="replaceable"><code>a</code></em>,
- <em class="replaceable"><code>b</code></em> or <em class="replaceable"><code>c</code></em></p></li><li><p><code class="literal">[<em class="replaceable"><code>a-z</code></em>]</code> matches
- any character in the range <em class="replaceable"><code>a</code></em> to
- <em class="replaceable"><code>z</code></em>, inclusive. A leading or trailing dash
- will be interpreted literally</p></li></ul></div><p>Since we use <code class="literal">java.util.regex</code> patterns to implement
- globs, this means that in addition to the above, a number of
- “<span class="quote">character class metacharacters</span>” 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.</p><div class="itemizedlist"><ul type="disc"><li><p><code class="literal">\w</code> matches any alphanumeric character or
- underscore</p></li><li><p><code class="literal">\s</code> matches a space or horizontal tab</p></li><li><p><code class="literal">\S</code> matches a printable
- non-whitespace.</p></li><li><p><code class="literal">\d</code> matches a decimal digit</p></li></ul></div><p>Here are some examples of glob patterns:</p><div class="itemizedlist"><ul type="disc"><li><p><strong class="userinput"><code>*</code></strong> - all files.</p></li><li><p><strong class="userinput"><code>*.java</code></strong> - all files whose names end with
- “<span class="quote">.java</span>”.</p></li><li><p><strong class="userinput"><code>*.[ch]</code></strong> - all files whose names end with
- either “<span class="quote">.c</span>” or “<span class="quote">.h</span>”.</p></li><li><p><strong class="userinput"><code>*.{c,cpp,h,hpp,cxx,hxx}</code></strong> - all C or C++
- files.</p></li><li><p><strong class="userinput"><code>[^#]*</code></strong> - all files whose names do not
- start with “<span class="quote">#</span>”.</p></li></ul></div><h2><a name="id2579546"></a>Using regexes instead of globs</h2><p>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 <code class="literal">(re)</code>, which will tell jEdit to
- not translate the following pattern into a regex (since it already is one).
- For example:</p><div class="glosslist"><dl><dt><code class="literal"> (re).*\.(h|c(c|pp)?) </code></dt><dd><p>Matches *.c, *.cpp, *.h, *.cc</p></dd></dl></div><p>If you need to match files that begin with the glob-translate-disable
- prefix <code class="literal">(re)</code>, you can escape it with a leading backslash
- and the metacharacters will be translated into globs as before.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="history.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="using-jedit-part.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="regexps.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix C. History Text Fields </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix E. Regular Expressions</td></tr></table></div></body></html>