how to negate a regexp match

Thus spake “Brent Easton”:

I would go the other way and say that the people who designed the Java
regex library made a serious error when they decided not to adopt the Perl
regex syntax.

Some other people agree with me, because ther are several Java PCRE (Perl-
compatible regex) libraries out there, in particular, one sponsored by
the Apache Foundation:

jakarta.apache.org/oro/index.html

I’d be inclined not to use java.util.regex at all, in favor of something
like this. Anyone who knows regexes is going to be annoyed by what Java
provides, and anyone who doesn’t know regexes won’t use them anyway, or
at least won’t have an opinion.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

I thought we just needed to change the way it is called from Pattern.match() to Matcher.find()?


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

That would fix the immediate behavior problem. It would not fix the goofy
not-quite-PCRE syntax, however, which I see as a more significant problem.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

*********** REPLY SEPARATOR ***********

On 13/05/2009 at 12:12 AM Joel Uckelman wrote:

Ok, was not aware of that, not being a regexper!

However, your statement ‘and anyone who doesn’t know regexes won’t use them anyway’ is not quite true. I know for a fact that regexps have been used in a number of modules in a basic form by a few of us people who don’t know how to use them. If, for instance, you where suddenly to enforce the need for ‘/’ delimiters on the expression, it will break plenty of modules.

In the mid to longer term, I want to completely replace the current Property Expression mechanism by a BeanShell solution that will fix a whole bucket load of problems with the current implementation. Perhaps we leave it as it is for now and fix it as part of this?

I have just started overhauling all of my Beanshell stuff for 3.2. I had planned just to introduce Calculated Properties, and inline Java expressions, but I should be able to do the Property Expressions also.

B.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

This is one of those things which we’ll be in a better position to fix
globally if we need to once we’re on the new site and we have somebody
looking after the module library…

Anyway, it would be better for people who don’t know regexes to learn
the standard kind, rather than the weird java.util.regex ones.

Sure.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

I had only stumbled onto the Pattern.matches() vs. Matcher.find() problem. Are you saying that there is another issue with Perl5 regex syntax not being used properly in java.util.regex? That would be odd… Do you have an example of a difference?

Cheers, jas…

Thus spake “jestew”:

Now that I look back to find my example of that, I realized that it’s not
because the regex syntax is not PCRE, but rather because you have to guard
every blasted backslash in Java Strings. Using a different regex library
would not save us from such uglies as “\s*\d+\\d+\s*”, because Java
doesn’t support uninterpreted strings (for which you use single quotes in
Perl).


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

What about the VASSAL code doing that for the user? Should be pretty simple, yes? That way the module designer would use normal regex syntax, and behind the scenes it would be escaped for them…

Cheers, jas…

On May 15, 2009, at 1:03 PM, jestew wrote:

The doubled-backslash is only an issue for Java code that programmers
write. Since that has to conform to the syntax rules for Java strings.

For backslashes that are entered into, say, a text field in a Swing
input form, the doubling will already be done for you. So the typical
end-user won’t see that.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Ah, cool. I’ve never done any Swing coding, just servlets… So then it shouldn’t be a problem using Matcher.find()

Thus spake “jestew”:

Yeah, so I was completely wrong here—what I don’t like about Java’s regex
implementation is something that I don’t like about using it with Strings.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)