You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dkozic <dr...@asw.eu> on 2008/10/02 15:11:07 UTC

Regular Expressions

Is there support for regular expressions as a language for Expressions and
Predicates in Camel?
-- 
View this message in context: http://www.nabble.com/Regular-Expressions-tp19778962s22882p19778962.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Regular Expressions

Posted by Peter Z <pz...@o2.pl>.


James.Strachan wrote:
> 
> There are some helper methods in the Java DSL in ExpressionBuilder;
> but we've not yet integrated it into the languages for use in XML or
> in the ExpressionClause class.
> 

In the Java DSL there are also method for check if message contains some
content.
I would like to know if it is possible to use 'contains' predicate in XML
configuration - I want to check if header contains some string.

P.

-- 
View this message in context: http://www.nabble.com/Regular-Expressions-tp19778962s22882p19800055.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Regular Expressions

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

You are Welcome. Its already there but its named: regex

    /**
     * Creates a predicate which is true if this expression matches the given
     * regular expression
     * 
     * @param regex the regular expression to match
     * @return a predicate which evaluates to true if the expression matches the
     *         regex
     */
    public Predicate<E> regex(String regex) {



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: dkozic [mailto:drazen.kozic@asw.eu] 
Sent: 2. oktober 2008 18:48
To: camel-user@activemq.apache.org
Subject: RE: Regular Expressions


This is what I am looking for. Thanks a lot!


Claus Ibsen wrote:
> 
> Hi
> 
> But it could be a good idea with a regexp(pattern) predicate add to a
> builder, so you can do it with the fluent builders?
> 
> I actually thought there was one already.
> 
> eg to filter all kind of test users in a route:
> from("activemq:orders").
> filter().header("username").regexp("$.*test^").to("seda:queue:justTests")
> .to("bean:processOrder");
> 
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: dkozic [mailto:drazen.kozic@asw.eu] 
> Sent: 2. oktober 2008 16:03
> To: camel-user@activemq.apache.org
> Subject: Re: Regular Expressions
> 
> 
> Thanks James
> 
> Bean language is just OK. I will create custom bean for regex pattern
> matching.
> 
> 
> James.Strachan wrote:
>> 
>> 2008/10/2 dkozic <dr...@asw.eu>:
>>>
>>> I need to inspect value of the body or value of the header against
>>> regular
>>> expression.
>>> It will be good if routing could be made after regexp matching.
>> 
>> For now the easiest way to do this is just invoke a Java method as an
>> expression within the routing logic.
>> http://activemq.apache.org/camel/bean-language.html
>> 
>>> Can you tell me more about helper methods you mentioned?
>> 
>> They are just helper methods for creating a regex expression for use in
>> the DSL
>> 
>> 
>> 
>> -- 
>> James
>> -------
>> http://macstrac.blogspot.com/
>> 
>> Open Source Integration
>> http://open.iona.com
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Regular-Expressions-tp19778962s22882p19779910.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Regular-Expressions-tp19778962s22882p19783151.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Regular Expressions

Posted by dkozic <dr...@asw.eu>.
This is what I am looking for. Thanks a lot!


Claus Ibsen wrote:
> 
> Hi
> 
> But it could be a good idea with a regexp(pattern) predicate add to a
> builder, so you can do it with the fluent builders?
> 
> I actually thought there was one already.
> 
> eg to filter all kind of test users in a route:
> from("activemq:orders").
> filter().header("username").regexp("$.*test^").to("seda:queue:justTests")
> .to("bean:processOrder");
> 
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: dkozic [mailto:drazen.kozic@asw.eu] 
> Sent: 2. oktober 2008 16:03
> To: camel-user@activemq.apache.org
> Subject: Re: Regular Expressions
> 
> 
> Thanks James
> 
> Bean language is just OK. I will create custom bean for regex pattern
> matching.
> 
> 
> James.Strachan wrote:
>> 
>> 2008/10/2 dkozic <dr...@asw.eu>:
>>>
>>> I need to inspect value of the body or value of the header against
>>> regular
>>> expression.
>>> It will be good if routing could be made after regexp matching.
>> 
>> For now the easiest way to do this is just invoke a Java method as an
>> expression within the routing logic.
>> http://activemq.apache.org/camel/bean-language.html
>> 
>>> Can you tell me more about helper methods you mentioned?
>> 
>> They are just helper methods for creating a regex expression for use in
>> the DSL
>> 
>> 
>> 
>> -- 
>> James
>> -------
>> http://macstrac.blogspot.com/
>> 
>> Open Source Integration
>> http://open.iona.com
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Regular-Expressions-tp19778962s22882p19779910.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Regular-Expressions-tp19778962s22882p19783151.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Regular Expressions

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

But it could be a good idea with a regexp(pattern) predicate add to a builder, so you can do it with the fluent builders?

I actually thought there was one already.

eg to filter all kind of test users in a route:
from("activemq:orders").
filter().header("username").regexp("$.*test^").to("seda:queue:justTests")
.to("bean:processOrder");




Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: dkozic [mailto:drazen.kozic@asw.eu] 
Sent: 2. oktober 2008 16:03
To: camel-user@activemq.apache.org
Subject: Re: Regular Expressions


Thanks James

Bean language is just OK. I will create custom bean for regex pattern
matching.


James.Strachan wrote:
> 
> 2008/10/2 dkozic <dr...@asw.eu>:
>>
>> I need to inspect value of the body or value of the header against
>> regular
>> expression.
>> It will be good if routing could be made after regexp matching.
> 
> For now the easiest way to do this is just invoke a Java method as an
> expression within the routing logic.
> http://activemq.apache.org/camel/bean-language.html
> 
>> Can you tell me more about helper methods you mentioned?
> 
> They are just helper methods for creating a regex expression for use in
> the DSL
> 
> 
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Regular-Expressions-tp19778962s22882p19779910.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Regular Expressions

Posted by dkozic <dr...@asw.eu>.
Thanks James

Bean language is just OK. I will create custom bean for regex pattern
matching.


James.Strachan wrote:
> 
> 2008/10/2 dkozic <dr...@asw.eu>:
>>
>> I need to inspect value of the body or value of the header against
>> regular
>> expression.
>> It will be good if routing could be made after regexp matching.
> 
> For now the easiest way to do this is just invoke a Java method as an
> expression within the routing logic.
> http://activemq.apache.org/camel/bean-language.html
> 
>> Can you tell me more about helper methods you mentioned?
> 
> They are just helper methods for creating a regex expression for use in
> the DSL
> 
> 
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Regular-Expressions-tp19778962s22882p19779910.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Regular Expressions

Posted by James Strachan <ja...@gmail.com>.
2008/10/2 dkozic <dr...@asw.eu>:
>
> I need to inspect value of the body or value of the header against regular
> expression.
> It will be good if routing could be made after regexp matching.

For now the easiest way to do this is just invoke a Java method as an
expression within the routing logic.
http://activemq.apache.org/camel/bean-language.html

> Can you tell me more about helper methods you mentioned?

They are just helper methods for creating a regex expression for use in the DSL



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Regular Expressions

Posted by dkozic <dr...@asw.eu>.
I need to inspect value of the body or value of the header against regular
expression.
It will be good if routing could be made after regexp matching.

Can you tell me more about helper methods you mentioned?

Thanks

James.Strachan wrote:
> 
> 2008/10/2 dkozic <dr...@asw.eu>:
>>
>> Is there support for regular expressions as a language for Expressions
>> and
>> Predicates in Camel?
> 
> There are some helper methods in the Java DSL in ExpressionBuilder;
> but we've not yet integrated it into the languages for use in XML or
> in the ExpressionClause class.
> 
> Could you give an example of how you'd like to use it? Is it to use a
> regex as a predicate?
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Regular-Expressions-tp19778962s22882p19779412.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Regular Expressions

Posted by James Strachan <ja...@gmail.com>.
2008/10/2 dkozic <dr...@asw.eu>:
>
> Is there support for regular expressions as a language for Expressions and
> Predicates in Camel?

There are some helper methods in the Java DSL in ExpressionBuilder;
but we've not yet integrated it into the languages for use in XML or
in the ExpressionClause class.

Could you give an example of how you'd like to use it? Is it to use a
regex as a predicate?

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com