|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.nsftools.zip.PatternMatch
public class PatternMatch
This class has a single method that allows you to determine whether or not a given string matches a given pattern. See the information in the isMatch method for more information.
If you're using the JDK (aka the J2SE) 1.4 or higher, you should probably use the java.util.regex package to make Regular Expressions to provide string pattern-matching functionality, because it will give you a much greater range of functionality. There are (at the time of this writing) some good examples of Regular Expression usage here on the Sun website.
For updates or more information about this program, please visit www.nsftools.com
Constructor Summary | |
---|---|
PatternMatch()
|
Method Summary | |
---|---|
boolean |
isMatch(java.lang.String checkString,
java.lang.String pattern)
Returns a boolean value indicating whether or not checkString matches the pattern. |
static void |
main(java.lang.String[] args)
The main method has been provided to allow you to test the class, and to give you an example of calling the isMatch method. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PatternMatch()
Method Detail |
---|
public static void main(java.lang.String[] args)
public boolean isMatch(java.lang.String checkString, java.lang.String pattern)
If you're matching a character range, it can be either single characters, like [abc], or a range of characters, like [a-c], or a combination, like [a-clmnx-z]. For example, the pattern 'b[aiu]t' would match 'bat', 'bit', and 'but', and the pattern 'a[1-9]' would match a1, a2, a3, a4, a5, a6, a7, a8, and a9.
This should all work much (exactly?) like file matching in DOS. For example, a pattern of '*.txt' should match all strings ending in '.txt', '*.*' should match all strings with a '.' in them, '*.???' should match strings with a three letter extension, and so on.
Also, please note that the pattern check IS case-sensitive. If you don't want it to be, you should convert the checkString and the pattern to lower-case as you're passing them.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |