Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent of java.util.regex for "glob" type patterns?

Tags:

java

glob

Is there a standard (preferably Apache Commons or similarly non-viral) library for doing "glob" type matches in Java? When I had to do similar in Perl once, I just changed all the "." to "\.", the "*" to ".*" and the "?" to "." and that sort of thing, but I'm wondering if somebody has done the work for me.

Similar question: Create regex from glob expression

like image 317
Paul Tomblin Avatar asked Aug 08 '09 02:08

Paul Tomblin


People also ask

Does glob support regex?

The pattern rules for glob are not regular expressions. Instead, they follow standard Unix path expansion rules. There are only a few special characters: two different wild-cards, and character ranges are supported. The patterns rules are applied to segments of the filename (stopping at the path separator, /).

What is Java util regex pattern?

A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern. They can be used to search, edit, or manipulate text and data. The java.util.regex package primarily consists of the following three classes −

What is glob pattern in Java?

What is a Glob? In programming, glob is a pattern using wildcards to specify filenames. For example, *. java is a simple and trivial glob. It specifies all files with extension 'java'.

What is glob style matching?

What are globs? Globs, also known as glob patterns are patterns that can expand a wildcard pattern into a list of pathnames that match the given pattern.


1 Answers

Globbing is also planned for implemented in Java 7.

See FileSystem.getPathMatcher(String) and the "Finding Files" tutorial.

like image 61
finnw Avatar answered Sep 19 '22 17:09

finnw