Monday, February 27, 2012

Branch and regular expressions

I don't know why but it just never clicked.  You can use regular expressions as the labels on your branch step even when evaluate labels is false.  A simple example is checking the http status values from a RESTful call:

  • Branch header->status
    • /^2[0-9][0-9]$/ (OK)
    • /^4[0-9][0-9]$/ (Non retry enabled error)
    • /^5[0-9][0-9]$/ (Retry enabled error)
Much easier than trying to list all combinations.

3 comments:

  1. Can you just elaobrate on usage of /^2[0-9][0-9]$/ value?
    as what means what in this?

    ReplyDelete
    Replies
    1. The ^ means start at the beginning. The 2 is literal, so it starts with a 2, and then 2 more numbers from 0-9, then the $ means an ending value.

      Basically, that looks for all HTTP 200 series messages.
      The /^4[0-9][0-9]$/ looks for all 400 series HTTP errors and the /^5[0-9][0-9]$/ looks for all 500 series HTTP errors.

      The ^ and $ make sure that something like 2000 won't match or 0200 won't match either.

      Delete
  2. hi,

    I am trying to take input as a document reference list. Under which there is a field 'Transport Mode'. I have to apply a logic, in the way, if the Transport Mode is AIR it should go in TRANS_AIR name document list, Else, it should go to some other Output list. I have applied MAP->Loop(Over the list)->Branch (Evaluate Label: True)->%Transport Mode%=="AIR":Sequence->MAP..But its not working..Could you please help me in this regards

    Thanks
    Surabhi Shah

    ReplyDelete