Hi,
We're trying to use jakarta-regexp-1.2 to match a list of computer names
against a user-supplied regular expression. We've run into a problem
where users try to give the beginning of a computer name to get a match of
allcomputers whose names begin with the string. What we're doing is
pretty similar to the example program below:
import org.apache.regexp.*;
public class retest {
public static void main(String[] args) {
String regexString = "^abc";
String comparisonString = "abcc";
try {
RE regex = REUtil.createRE(regexString, RE.MATCH_NORMAL |
RE.MATCH_SINGLELINE);
if (regex.match(comparisonString) ) {
System.out.println("string " + comparisonString + " matches regex" +
regexString);
} else {
System.out.println("string " + comparisonString + " doesn't match
regex " + regexString);
}
} catch (Exception exc) {
System.err.println("caught exception " + exc.getMessage() );
}
}
}
Suprisingly, this always returns "string abcc doesn't match regex ^abc".
It seems like "^abc" should match against "abcc". Am I setting my match
flags wrong, or will "^abc" only match "abcc" if there's a newline in
front of "abcc"?
Thanks........... Larry
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>