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!
=== Introduction === Surely you have used globs before (maybe even without knowing that they call them "globs"): *.txt dir/*.doc execut?r.txt Globs are a widely spread concept that is used throughout the UNIX, MICROSOFT and other "worlds". All implementations support at least the following elements: {| class="wikitable" !Construct !!Matches |- |<tt>?</tt> ||Any character except the file separator ("<code>/</code>" and/or "<code>\</code>") |- |<tt>*</tt> ||Zero or more characters except the file separator |- |<tt>''x''</tt>||The character <tt>''x''</tt> |} Some implementations add more features: {| class="wikitable" !Construct !!Matches |- |<tt>[abc]</tt> ||Exactly one of the characters "<tt>a</tt>", "<tt>b</tt>" and "<tt>c</tt>" |- |<tt>[^abc]</tt><br />or<br /><tt>[!abc]</tt>||Any character ''except'' "<tt>a</tt>", "<tt>b</tt>" or "<tt>c</tt>" |- |<tt>[A-Za-z]</tt> ||Any (latin) letter |- |<tt>**</tt> ||Zero or more characters (''including'' the file separator) |- |<tt>\''X''</tt> ||"<tt>''X''</tt>", even if "<tt>''X''</tt>" is a meta character |} Since version 1.7 JAVA provides [http://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher%28java.lang.String%29 its own implementation] of "glob matching", which adds another (quite uncommon) construct: {| class="wikitable" !Construct !!Matches |- |<tt>{''alpha'',''beta'',''gamma''}</tt>||Any of "<tt>alpha</tt>", "<tt>beta</tt>" or "<tt>gamma</tt>" |} All in all, globs are very practical, though not very powerful. This is why <code>de.unkrig.commons</code> provides yet another implementation, as follows:
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