X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fcom%2Fstevesoft%2Fpat%2FFileRegex.java;h=06a52667e1568e6b5c1da6e42acd34056bb052eb;hb=39c97de2f7b8ef87b42f121f37d4f158d1651fe9;hp=342d41c17c9a1db3fc7da3aaa357193f352c0bc4;hpb=506d60f0e188723ddc91c26824b41ac7034df3fe;p=jalview.git diff --git a/src/com/stevesoft/pat/FileRegex.java b/src/com/stevesoft/pat/FileRegex.java index 342d41c..06a5266 100755 --- a/src/com/stevesoft/pat/FileRegex.java +++ b/src/com/stevesoft/pat/FileRegex.java @@ -7,61 +7,65 @@ // package com.stevesoft.pat; -import java.io.*; -import java.util.*; +import java.io.File; +import java.util.StringTokenizer; +import java.util.Vector; /** * This class is a different form of Regex designed to work more like the file * matching utility of a Unix shell. It is implemented by some simple string - * transformations:
+ * transformations:
+ *
* - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * - *
FileRegex Regex FileRegexRegex
* .* *.*
. \. .\.
{ (?: {(?:
{?! (?! {?!(?!
{?= (?= {?=(?=
{?? (?? {??(??
} ) )
? . ?.
{,} (|)
Note that a FileRegex pattern always ends with the Regex - * pattern element "$". If you like to experiment, try making FileRegex's and - * then printing them out. The toString() method does a decompile of the pattern - * to a standard Regex. Here are some more complete examples:
{,} + * + *
(|)
+ *
Note that a FileRegex pattern always ends with the Regex pattern + * element "$". If you like to experiment, try making FileRegex's and then + * printing them out. The toString() method does a decompile of the pattern to a + * standard Regex. Here are some more complete examples:
* - * - * + * + * * - * - * + * + * * - * - * + * + * * - * - * - *
FileRegex Regex FileRegexRegex
*.java .*\.java$ *.java.*\.java$
*.{java,html} .*\.(java|html)$ *.{java,html}.*\.(java|html)$
foo.[chC] foo.[chC]$
+ * foo.[chC] + * foo.[chC]$ + * + * */ public class FileRegex extends Regex { @@ -82,8 +86,7 @@ public class FileRegex extends Regex * Compile a new pattern. Throws * * @exception com.stevesoft.pat.RegSyntax - * for nonsensical patterns like "[9-0]+" just as Regex - * does. + * for nonsensical patterns like "[9-0]+" just as Regex does. * @see com.stevesoft.pat#compile(java.lang.String) */ public void compile(String s) throws RegSyntax @@ -159,8 +162,8 @@ public class FileRegex extends Regex return sa; } - final static Regex root = new Regex(File.separatorChar == '/' ? "/$" - : "(?:.:|)\\\\$"); + final static Regex root = new Regex( + File.separatorChar == '/' ? "/$" : "(?:.:|)\\\\$"); static void list1(String path, Vector v, int df, boolean rec) {