PageRenderTime 57ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. <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
  2. to implement file name filters in the file system browser. Glob patterns
  3. resemble regular expressions somewhat, but have a much simpler syntax. The
  4. following character sequences have special meaning within a glob
  5. 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
  6. anything that does <span class="emphasis"><em>not</em></span> match
  7. <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>
  8. matches any one of <em class="replaceable"><code>a</code></em>,
  9. <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
  10. any character in the set <em class="replaceable"><code>a</code></em>,
  11. <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
  12. any character not in the set <em class="replaceable"><code>a</code></em>,
  13. <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
  14. any character in the range <em class="replaceable"><code>a</code></em> to
  15. <em class="replaceable"><code>z</code></em>, inclusive. A leading or trailing dash
  16. will be interpreted literally</p></li></ul></div><p>Since we use <code class="literal">java.util.regex</code> patterns to implement
  17. globs, this means that in addition to the above, a number of
  18. &#8220;<span class="quote">character class metacharacters</span>&#8221; may be used. Keep in mind,
  19. their usefulness is limited since the regex quantifier metacharacters
  20. (asterisk, questionmark, and curly brackets) are redefined to mean something
  21. else in filename glob language, and the regex quantifiers are not available
  22. in glob language.</p><div class="itemizedlist"><ul type="disc"><li><p><code class="literal">\w</code> matches any alphanumeric character or
  23. 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
  24. 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
  25. &#8220;<span class="quote">.java</span>&#8221;.</p></li><li><p><strong class="userinput"><code>*.[ch]</code></strong> - all files whose names end with
  26. either &#8220;<span class="quote">.c</span>&#8221; or &#8220;<span class="quote">.h</span>&#8221;.</p></li><li><p><strong class="userinput"><code>*.{c,cpp,h,hpp,cxx,hxx}</code></strong> - all C or C++
  27. files.</p></li><li><p><strong class="userinput"><code>[^#]*</code></strong> - all files whose names do not
  28. start with &#8220;<span class="quote">#</span>&#8221;.</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
  29. glob for specifying file sets. This is because regular expressions are more
  30. powerful than globs and can provide the user with more specific filename
  31. matching criteria. To avoid the glob-to-regex transformation, prefix your
  32. pattern with the string <code class="literal">(re)</code>, which will tell jEdit to
  33. not translate the following pattern into a regex (since it already is one).
  34. 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
  35. prefix <code class="literal">(re)</code>, you can escape it with a leading backslash
  36. 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>