public class FileRegex extends Regex
FileRegex | Regex |
* | .* |
. | \. |
{ | (?: |
{?! | (?! |
{?= | (?= |
{?? | (?? |
} | ) |
? | . |
{,} | (|) |
FileRegex | Regex |
*.java | .*\.java$ |
*.{java,html} | .*\.(java|html)$ |
foo.[chC] | foo.[chC]$ |
dotDoesntMatchCR, esc
charsMatched_, 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, version
charsMatched, charsMatched, copyOutOf, didMatch, equals, getString, getStringLike, left, left, matchedFrom, matchedFrom, matchedTo, matchedTo, matchFrom, matchFrom, numSubs, right, right, stringMatched, stringMatched, substring, substring
public FileRegex()
public FileRegex(String s)
public void compile(String s) throws RegSyntax
compile
in class Regex
RegSyntax
- is thrown if a syntax error is encountered
in the pattern.
For example, "x{3,1}" or "*a" are not valid
patterns.com.stevesoft.pat
public 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 FilenameFilter
accept
in class Regex
dir
- 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.FileRegex
public static String[] list(String f)
public static String toFileRegex(String s)