Using regular expressions in labels

I just noticed that there was a few questions on a “competing” discussion group (no, not Advantage) about being able use a single FLOW step to determine if a string if null, empty, has spaces, etc. I thought I’d share some info on using regular expressions as labels.

The syntax is described in an appendix in the B2B Integrator/IS Developer Guide. For labels, the expression must be surrounded by slashes.

Here’s a flow example:

BRANCH on ‘/tailOfAK5’
/.+/: MAP (tailOfAK5 has one or more chars, maybe spaces)
$default: SEQUENCE (tailOfAK5 is empty or null)

Other examples:

Selected if branch switch has one or more characters, including just spaces. Strings that are $null or are empty will not be selected by this label (e.g. the branch won’t take this path). Strings that have only spaces WILL take this branch.

Selected if branch switch starts with the characters “ISA”.

/[^ ]/
Selected if branch switch not null, not empty, and contains at least one non-space character.

/[^ \t\r\n]/
Selected if branch switch not null, not empty, and contains at least one non-whitespace character.

Ain’t it cool? :slight_smile:


Way cool! Thanks Rob! I’ve found your regex tips very useful!
How about an ezine article on regular expressions? :slight_smile:


Does the expression /[^ ]/ work for wM v6.1 ?

I know it works on v6.5

Yes , it does work for 6.1.

I’ve a scenario where I want to put in a test scenario:

If document A is empty or null, throw error
Else if there is data, proceed to next step.

I’ve tried to do this by setting this branch statement:
Branch on /documentA
/[^ ]/ - Process
$default - Throw error

This works if documentA is null (no tags at all).
But if documentA has tags (empty), it’ll go to the /[^ ]/ section.

Is there any other way i can do this?

Helo Everyone,
Can u please tell me how to use If condition in an Sequence as well as tell me about LABELS and SWITCH in weMethods 6.0

These two basic uses of the BRANCH statement are covered in the Developer User’s Guide. Please review that and the feel free to ask any specific questions here.


Hello Bluewave,

What do you mean by Tags? Looks like it is not blanks. Check out what is the hex code of these tags. That could help to resolve.


This regular expression works only on strings. If you have a document, it won’t work as you seem to expect. An “empty” document isn’t a common thing to test for (other than comparing with $null)–usually you test for the presence of a field or two within the document.