Regular Expressions

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Regular Expressions

dkozic-2
Is there support for regular expressions as a language for Expressions and Predicates in Camel?
Reply | Threaded
Open this post in threaded view
|

Re: Regular Expressions

jstrachan
2008/10/2 dkozic <[hidden email]>:
>
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Regular Expressions

dkozic-2
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 <drazen.kozic@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
Reply | Threaded
Open this post in threaded view
|

Re: Regular Expressions

jstrachan
2008/10/2 dkozic <[hidden email]>:
>
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Regular Expressions

dkozic-2
Thanks James

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

James.Strachan wrote
2008/10/2 dkozic <drazen.kozic@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
Reply | Threaded
Open this post in threaded view
|

RE: Regular Expressions

Claus Ibsen
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:[hidden email]]
Sent: 2. oktober 2008 16:03
To: [hidden email]
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 <[hidden email]>:
>>
>> 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.

Reply | Threaded
Open this post in threaded view
|

RE: Regular Expressions

dkozic-2
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 <drazen.kozic@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.
Reply | Threaded
Open this post in threaded view
|

RE: Regular Expressions

Claus Ibsen
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:[hidden email]]
Sent: 2. oktober 2008 18:48
To: [hidden email]
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:[hidden email]]
> Sent: 2. oktober 2008 16:03
> To: [hidden email]
> 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 <[hidden email]>:
>>>
>>> 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.

Reply | Threaded
Open this post in threaded view
|

Re: Regular Expressions

Peter Z
In reply to this post by jstrachan

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.