You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by dave- <da...@pacbell.net> on 2004/12/22 02:25:52 UTC

processing when a pattern does NOT match

Is there a way to process the block when a match pattern doesn't match? 
Can this be done using either sitemap or regexpr syntax?  TIA -dave

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


RE: processing when a pattern does NOT match

Posted by David Leangen <dl...@canada.com>.
Ok, thanks!

Please let me know when you figure this out. You've got me curious now! ;-)


Cheers,
Dave



> -----Original Message-----
> From: Morus Walter [mailto:morus.walter@tanto.de]
> Sent: 22 December 2004 21:44
> To: dleangen@canada.com
> Cc: users@cocoon.apache.org
> Subject: RE: processing when a pattern does NOT match
> 
> 
> Hi David,
> > 
> > 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));
> > 
> Sure.
> ^[^(test)].*
> matches any text that does not start with '(', 't', 'e', 's', 't' or ')'
> and contains at least one character.
> 
> But if you'd test, if it matches 'est' or '(test)' or 'sssss' I say that 
> you'll find, that it doesn't.
> If I followed the discussion correctly, it should match since 
> 'est' or 'sssss'
> or '(test)' isn't 'test'.
> 
> Morus
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org

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


RE: processing when a pattern does NOT match

Posted by Morus Walter <mo...@tanto.de>.
Hi David,
> 
> 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));
> 
Sure.
^[^(test)].*
matches any text that does not start with '(', 't', 'e', 's', 't' or ')'
and contains at least one character.

But if you'd test, if it matches 'est' or '(test)' or 'sssss' I say that 
you'll find, that it doesn't.
If I followed the discussion correctly, it should match since 'est' or 'sssss'
or '(test)' isn't 'test'.

Morus

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


RE: processing when a pattern does NOT match

Posted by David Leangen <dl...@canada.com>.
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


RE: processing when a pattern does NOT match

Posted by Morus Walter <mo...@tanto.de>.
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


RE: processing when a pattern does NOT match

Posted by David Leangen <dl...@canada.com>.
Dave (nice name!),

This is taken from the Java API:

Character classes
[abc] 	a, b, or c (simple class)
[^abc] 	Any character except a, b, or c (negation)
[a-zA-Z] 	a through z or A through Z, inclusive (range)
[a-d[m-p]] 	a through d, or m through p: [a-dm-p] (union)
[a-z&&[def]] 	d, e, or f (intersection)
[a-z&&[^bc]] 	a through z, except for b and c: [ad-z] (subtraction)
[a-z&&[^m-p]] 	a through z, and not m through p: [a-lq-z](subtraction)


Conclusion: try the "^" operator. For example: "^[^(test)].*"

Please let me know when you figure this out.


Cheers,
Dave




> -----Original Message-----
> From: dave- [mailto:dave-@pacbell.net]
> Sent: 22 December 2004 18:31
> To: users@cocoon.apache.org
> Subject: Re: processing when a pattern does NOT match
> 
> 
> I seem to be unable to find any documentation that Java regexp has a 
> negate (!) operator.  In any case, I have been unable to get it to work 
> in cocoon.
> 
> I tried <map:match pattern="!^test1" ... and it did not work.  Also the 
> regexp java testing applet seems to consider "!" pumctuation.
> 
> Tony Collen wrote:
> 
> > dave- wrote:
> >
> >> Is there a way to process the block when a match pattern doesn't 
> >> match? Can this be done using either sitemap or regexpr syntax?  TIA 
> >> -dave
> >
> >
> > Use the Regexp matcher, write your regexp and just use the negate (!) 
> > operator.
> >
> > Tony
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org

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


Re: processing when a pattern does NOT match

Posted by dave- <da...@pacbell.net>.
I seem to be unable to find any documentation that Java regexp has a 
negate (!) operator.  In any case, I have been unable to get it to work 
in cocoon.

I tried <map:match pattern="!^test1" ... and it did not work.  Also the 
regexp java testing applet seems to consider "!" pumctuation.

Tony Collen wrote:

> dave- wrote:
>
>> Is there a way to process the block when a match pattern doesn't 
>> match? Can this be done using either sitemap or regexpr syntax?  TIA 
>> -dave
>
>
> Use the Regexp matcher, write your regexp and just use the negate (!) 
> operator.
>
> Tony
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


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


Re: processing when a pattern does NOT match

Posted by Tony Collen <co...@umn.edu>.
dave- wrote:
> Is there a way to process the block when a match pattern doesn't match? 
> Can this be done using either sitemap or regexpr syntax?  TIA -dave

Use the Regexp matcher, write your regexp and just use the negate (!) 
operator.

Tony

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