You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Sorin Silaghi <so...@gmail.com> on 2011/12/23 11:15:41 UTC

Can someone please explain to me how regex should work as simple OP?

Hi,


              I've been trying everything I can imagine and nothing seems
towork. All I need is to check if the message starts with the OK string. I
tried the example below and every variation I could think of. I even tried
the example from the documentation '\d{4}' but it doesn't match a body
containing 4 digits.

            <verbose>
                <choice>
                    <when>
                        <simple>${body} regex '/^OK.*/s'</simple>
                        <setBody>
                            <constant>Something else</constant>
                        </setBody>
                    </when>
                </choice>
            </verbose>


best regards,
                      Sorin.

Re: Can someone please explain to me how regex should work as simple OP?

Posted by Willem Jiang <wi...@gmail.com>.
I just added some tests which are based on you description.
Please check them[1] out.

BTW, I think you need to replace the / to \.

[1]http://svn.apache.org/viewvc?rev=1224673&view=rev

On Fri Dec 23 18:15:41 2011, Sorin Silaghi wrote:
> Hi,
>
>
>                I've been trying everything I can imagine and nothing seems
> towork. All I need is to check if the message starts with the OK string. I
> tried the example below and every variation I could think of. I even tried
> the example from the documentation '\d{4}' but it doesn't match a body
> containing 4 digits.
>
>              <verbose>
>                  <choice>
>                      <when>
>                          <simple>${body} regex '/^OK.*/s'</simple>
>                          <setBody>
>                              <constant>Something else</constant>
>                          </setBody>
>                      </when>
>                  </choice>
>              </verbose>
>
>
> best regards,
>                        Sorin.
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang