cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Leangen" <dlean...@canada.com>
Subject RE: processing when a pattern does NOT match
Date Wed, 22 Dec 2004 12:27:10 GMT

Hi, Morus,

I'm not familiar, either, with how regexp works in Cocoon. If I'm not
mistaken, though, it is based on Java.

FYI: I tried this as a JUnit test and it passed. I'm not saying that it's
correct, though.

        final String pattern = "^[^(test)].*";
        assertFalse("test".matches(pattern));
        assertTrue("atest".matches(pattern));
        assertFalse("testAbc".matches(pattern));


Cheers,
Dave



> -----Original Message-----
> From: Morus Walter [mailto:morus.walter@tanto.de]
> Sent: 22 December 2004 20:57
> To: users@cocoon.apache.org; dleangen@canada.com
> Subject: RE: processing when a pattern does NOT match
>
>
> David Leangen writes:
> >
> >
> > Conclusion: try the "^" operator. For example: "^[^(test)].*"
> >
> > Please let me know when you figure this out.
> >
> No. That cannot work.
> ^ is defined within character classes only as negation.
> Outside it means the start of the string (`^a' matches `ab' but not `ba'
> whereas `a' matches both).
>
> Probably something can be done using negative lookaheads but I'm not sure
> and don't have enough experience with cocoon to say, if that would work in
> that context.
>
> E.g.
> ^(?=foo)
> matches every string starting with foo
> ^(?!foo)
> strings not starting with foo.
> In both cases the RE does not consume the matched/forbidden text (while
> ^foo does).
> I guess ^(?!foo$) should match any text not beeing 'foo'.
> (briefly tested with perl)
>
> Morus


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message