public class FileRegex extends Regex
| FileRegex | Regex |
| * | .* |
| . | \. |
| { | (?: |
| {?! | (?! |
| {?= | (?= |
| {?? | (?? |
| } | ) |
| ? | . |
| {,} | (|) |
| FileRegex | Regex |
| *.java | .*\.java$ |
| *.{java,html} | .*\.(java|html)$ |
| foo.[chC] | foo.[chC]$ |
dotDoesntMatchCR, esccharsMatched_, didMatch_, marks, matchFrom_, numSubs_, src| Constructor and Description |
|---|
FileRegex()
Build an unitialized FileRegex.
|
FileRegex(String s)
Build a FileRegex form String s.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(File dir,
String s)
This is the method required by FileNameFilter.
|
void |
compile(String s)
Compile a new pattern.
|
boolean |
isLiteral()
Checks to see if there are only literal and no special
pattern elements in this Regex.
|
static String[] |
list(String f)
Provides an alternative to File.list -- this
separates its argument according to File.pathSeparator.
|
static String |
toFileRegex(String s)
This method takes a file regular expression, and translates it
into the type of pattern used by a normal Regex.
|
add, clone, compile1, countMaxChars, countMinChars, define, define, equals, getDefaultMFlag, getDontMatchInQuotes, getGFlag, getIgnoreCase, getMFlag, getReplacer, getReplaceRule, getSFlag, isDefined, matchAt, matchAt, optimize, optimized, perlCode, replaceAll, replaceAll, replaceAllFrom, replaceAllRegion, replaceFirst, replaceFirstFrom, replaceFirstRegion, result, reverseSearch, reverseSearch, search, search, searchFrom, searchFrom, searchRegion, setDefaultMFlag, setDontMatchInQuotes, setGFlag, setIgnoreCase, setReplaceRule, setReplaceRule, toString, undefine, versioncharsMatched, charsMatched, copyOutOf, didMatch, equals, getString, getStringLike, left, left, matchedFrom, matchedFrom, matchedTo, matchedTo, matchFrom, matchFrom, numSubs, right, right, stringMatched, stringMatched, substring, substringpublic FileRegex()
public FileRegex(String s)
public void compile(String s) throws RegSyntax
compile in class RegexRegSyntax - is thrown if a syntax error is encountered
in the pattern.
For example, "x{3,1}" or "*a" are not valid
patterns.com.stevesoft.patpublic boolean accept(File dir, String s)
File dot = new File(".");
FileRegex java_files = new FileRegex("*.java");
String[] file_list = dot.list(java_files);
accept in interface FilenameFilteraccept in class Regexdir - The File instance for the directory being reads - The name of the file to testtrue if the file should be included in the list,
false otherwise.FileRegexpublic static String[] list(String f)
public static String toFileRegex(String s)