Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regex weirdness



"Todd O'Bryan" <email@hidden> wrote:

>Maybe I'm expecting these things to be too smart. ...
>Maybe I'm being overly optimistic, ...

Maybe those are significant factors. Really.


>It seems
>that if one pattern is a sub-string of another, it doesn't work, which
>would be consistent with your explanation.

"It doesn't work" is incorrect. It DOES work: when you provide patterns in
accordance with how | behaves (left to right, stop on first match). It's
only a pattern-engine, after all.


>I still tend to think that's a bug.

Then you should file a bug with Sun. Sun is the ultimate authority on how
Java's regexes behave.

I do not think it's a bug. It makes complete sense to me given the
individual behavior of the operators.

The whole area of look-around behavior isn't necessarily what one might
first think. I found this particularly informative, especially the
sections on Regex Engine Internals and the one section entitled "Important
Notes About Lookbehind":
<http://www.regular-expressions.info/lookaround.html>


>In the Camel Book, they suggest that patt2 is found and then the
>matcher looks *back* in the string to try to match (or not match for
>negative assertions) patt1.

Why would what it says in the Camel Book have any bearing on how Java
regex's work?

Java isn't Perl.

Even if we take Perl's regex as gospel, you said "they suggest", which
makes it uncertain whether this is a precise specification of actual
algorithmic behavior, or merely a metaphor. If it's a metaphor, then as we
all know, metaphors eventually break down.

If you can find a comprehensive specification of Java's regex, and create a
case that the behavior does not match the spec, then you'll have something
to file with your bug-report. I couldn't even find the comprehensive spec.

Good luck.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.