From: <Dou...@gr...> - 2002-02-11 16:28:55
|
I'm using the re module with Jython embedded in my Java app to handle the pattern matching. I'm struggling with the regular expression syntax to perform a negation of a pattern. Specifically, for a date I want to allow DD-MMM-YY (JAN, MAR,etc for the month value) so I want my match object to be returned only for items that don't match this pattern. r=re.compile('[0123][0-9][-]\w{3}[-][01][0123]').search("12-DEC-02") //this returns a match object How can I wrapper this pattern and negate it so the failure to find the pattern is what is returned? I've tried variations similar to the snippet below to group and negate without success. r=re.compile('^([0123][0-9][-]\w{3}[-][01][0123])').search("12-DEC-02") I have looked at the Mastering Regular Expressions book which is some help but is heavily Perl slanted. The re module documentation doesn't delve into my particular issue sufficiently (or I just missed it). Any recommendations for additional reference resources in addition to some help with the current problem would be welcome. Thanks, Doug |