PageRenderTime 53ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/doc/users-guide/globs.xml

#
XML | 137 lines | 107 code | 27 blank | 3 comment | 0 complexity | e235829d7cced2c541761624033ef9b8 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. <?xml version="1.0" encoding="UTF-8"?>
  2. <appendix id="globs">
  3. <title>Glob Patterns</title>
  4. <!-- jEdit buffer-local properties: -->
  5. <!-- :indentSize=1:noTabs=true: -->
  6. <!-- :xml.root=users-guide.xml: -->
  7. <para>jEdit uses glob patterns similar to those in the various Unix shells
  8. to implement file name filters in the file system browser. Glob patterns
  9. resemble regular expressions somewhat, but have a much simpler syntax. The
  10. following character sequences have special meaning within a glob
  11. pattern:</para>
  12. <itemizedlist>
  13. <listitem>
  14. <para><literal>?</literal> matches any one character</para>
  15. </listitem>
  16. <listitem>
  17. <para><literal>*</literal> matches any number of characters</para>
  18. </listitem>
  19. <listitem>
  20. <para><literal>{!<replaceable>glob</replaceable>}</literal> Matches
  21. anything that does <emphasis>not</emphasis> match
  22. <replaceable>glob</replaceable></para>
  23. </listitem>
  24. <listitem>
  25. <para><literal>{<replaceable>a</replaceable>,<replaceable>b</replaceable>,<replaceable>c</replaceable>}</literal>
  26. matches any one of <replaceable>a</replaceable>,
  27. <replaceable>b</replaceable> or <replaceable>c</replaceable></para>
  28. </listitem>
  29. <listitem>
  30. <para><literal>[<replaceable>abc</replaceable>]</literal> matches
  31. any character in the set <replaceable>a</replaceable>,
  32. <replaceable>b</replaceable> or <replaceable>c</replaceable></para>
  33. </listitem>
  34. <listitem>
  35. <para><literal>[^<replaceable>abc</replaceable>]</literal> matches
  36. any character not in the set <replaceable>a</replaceable>,
  37. <replaceable>b</replaceable> or <replaceable>c</replaceable></para>
  38. </listitem>
  39. <listitem>
  40. <para><literal>[<replaceable>a-z</replaceable>]</literal> matches
  41. any character in the range <replaceable>a</replaceable> to
  42. <replaceable>z</replaceable>, inclusive. A leading or trailing dash
  43. will be interpreted literally</para>
  44. </listitem>
  45. </itemizedlist>
  46. <para>Since we use <literal>java.util.regex</literal> patterns to implement
  47. globs, this means that in addition to the above, a number of
  48. <quote>character class metacharacters</quote> may be used. Keep in mind,
  49. their usefulness is limited since the regex quantifier metacharacters
  50. (asterisk, questionmark, and curly brackets) are redefined to mean something
  51. else in filename glob language, and the regex quantifiers are not available
  52. in glob language.</para>
  53. <itemizedlist>
  54. <listitem>
  55. <para><literal>\w</literal> matches any alphanumeric character or
  56. underscore</para>
  57. </listitem>
  58. <listitem>
  59. <para><literal>\s</literal> matches a space or horizontal tab</para>
  60. </listitem>
  61. <listitem>
  62. <para><literal>\S</literal> matches a printable
  63. non-whitespace.</para>
  64. </listitem>
  65. <listitem>
  66. <para><literal>\d</literal> matches a decimal digit</para>
  67. </listitem>
  68. </itemizedlist>
  69. <para>Here are some examples of glob patterns:</para>
  70. <itemizedlist>
  71. <listitem>
  72. <para><userinput>*</userinput> - all files.</para>
  73. </listitem>
  74. <listitem>
  75. <para><userinput>*.java</userinput> - all files whose names end with
  76. <quote>.java</quote>.</para>
  77. </listitem>
  78. <listitem>
  79. <para><userinput>*.[ch]</userinput> - all files whose names end with
  80. either <quote>.c</quote> or <quote>.h</quote>.</para>
  81. </listitem>
  82. <listitem>
  83. <para><userinput>*.{c,cpp,h,hpp,cxx,hxx}</userinput> - all C or C++
  84. files.</para>
  85. </listitem>
  86. <listitem>
  87. <para><userinput>[^#]*</userinput> - all files whose names do not
  88. start with <quote>#</quote>.</para>
  89. </listitem>
  90. </itemizedlist>
  91. <bridgehead>Using regexes instead of globs</bridgehead>
  92. <para>Sometimes it is desirable to use a regular expression instead of a
  93. glob for specifying file sets. This is because regular expressions are more
  94. powerful than globs and can provide the user with more specific filename
  95. matching criteria. To avoid the glob-to-regex transformation, prefix your
  96. pattern with the string <literal>(re)</literal>, which will tell jEdit to
  97. not translate the following pattern into a regex (since it already is one).
  98. For example:</para>
  99. <glosslist>
  100. <glossentry>
  101. <glossterm><literal> (re).*\.(h|c(c|pp)?) </literal></glossterm>
  102. <glossdef>
  103. <para>Matches *.c, *.cpp, *.h, *.cc</para>
  104. </glossdef>
  105. </glossentry>
  106. </glosslist>
  107. <para>If you need to match files that begin with the glob-translate-disable
  108. prefix <literal>(re)</literal>, you can escape it with a leading backslash
  109. and the metacharacters will be translated into globs as before.</para>
  110. </appendix>