Editing
Using Globs
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Regular expressions features === First, [http://commons.unkrig.de/commons-text/apidocs/index.html?de/unkrig/commons/text/pattern/Pattern2.html <code>de.unkrig.commons.text.pattern.Pattern2</code>] combines the simplicity of globs with the full power of [http://docs.oracle.com/javase/7/docs/api/index.html?java/util/regex/Pattern.html JAVA regular expressions]. It does so by modifying a few characters in the glob before feeding it to <code>java.util.text.pattern.Pattern.compile()</code>, making that effectively a glob compiler: {| class="wikitable" !Glob construct!!Regex construct !!Matches |- |<tt>?</tt> ||<tt>[^/\\!]*</tt>||Any character except the file separator and "!" |- |<tt>*</tt> ||<tt>[^/\\!]*</tt>||Zero or more characters except the file separator and "!" |- |<tt>**</tt> ||<tt>[^!]*</tt> ||Zero or more characters except "!" |- |<tt>***</tt> ||<tt>.*</tt> ||Zero or more characters |- |<tt>.</tt>||<tt>\.</tt>||The dot is a literal (not a character class as in a regular expression) |- |} If you have not yet worked with regular expressions: JAVA regular expressions are very powerful and introduce many constructs and meta characters. Find the complete reference documentation [http://docs.oracle.com/javase/7/docs/api/index.html?java/util/regex/Pattern.html here]. Since "<tt>?</tt>" and "<tt>*</tt>" are not quantifiers as in regular expression ("<tt>?</tt>" == zero-or-one, "<tt>*</tt>" == zero-or-more), one has to use "<tt>{0,1}</tt>" and "<tt>{0,}</tt>" instead. The alternative notation for "<tt>.</tt>" ("any character") is "<tt>[^]</tt>". Find the reference documentation [http://commons.unkrig.de/javadoc/index.html?de/unkrig/commons/text/pattern/Pattern2.html here]. The API of [http://commons.unkrig.de/commons-text/apidocs/index.html?de/unkrig/commons/text/pattern/Pattern2.html <code>de.unkrig.commons.text.pattern.Pattern2</code>] is totally compatible with that of [http://docs.oracle.com/javase/7/docs/api/index.html?java/util/regex/Pattern.html <code>java.util.pattern.Pattern</code>], plus it adds a new compilation Flag <code>Pattern2.WILDCARD</code> that modifies the expression syntax from regex to globs.
Summary:
Please note that all contributions to unkrig.de may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Unkrig.de:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help
Tools
What links here
Related changes
Special pages
Page information