Orchestrator Functions and Regular Expressions (Regex)

imageThere are a number of ways to manipulate data using the Orchestrator built-in Activities. Text manipulation is a common need with Runbooks. An Activity pulls a string of data that you need only a part of, or need it in a different format. Fortunately, Orchestrator has many built-in Functions that can be used to further manipulate strings. Use these tools in the same places you would subscribe to data and they will be processed.

For example, the string below will be converted to all UPPERCASE.

[Upper('this will be inserted in upper case')]

You must enclose the entire string to be manipulated in square brackets, with the command and the string. Some other commands

Here’s the link to Orchestrator Functions

Functions

http://technet.microsoft.com/en-us/library/hh440537.aspx

Function and Definition

Upper - converts text to uppercase.

Lower - converts text to lowercase.

Field - returns text in a specific position.

Sum - returns the sum of a set of numbers.

Diff - returns the difference of two numbers.

Mult - returns the product of a set of numbers.

Div - returns the quotient of two numbers.

Instr - returns the position of first occurrence of text within another text.

Right - returns a subset of the text from the right side of the full text.

Left - returns a subset of the text from the left side of the full text.

Mid - returns a subset of the text from the middle of the full text.

LTrim - trims leading spaces from text.

RTrim - trims the trailing spaces from text.

Trim - trims leading and trailing spaces from text.

Len - returns the length of text.

 

Regular Expressions

https://technet.microsoft.com/en-us/library/hh440535.aspx

Regular expressions let you match a string to a pattern. This is a bit more complex, but allows for pulling really anything you need from a string.

Character

Meaning

.

Matches any character except a newline.

*

Matches the preceding item 0 or more times. For example, the "a*" pattern matches any string of a's in a row "a", "aaa", "aaaaaaaaaaaa", and an empty string "". To match any string of any character, use a dot followed by an asterisk. For example "a.*" matches any text that begins with the letter "a" and ends with any string of characters such as "abbb", "abcdef", or "automatic restart".

+

Matches the preceding item 1 or more times. This is like * but you must have a least 1 of the preceding item to make a match. For example, the "ab+" pattern matches "abbbbb", "ab", but does not match "a". To contrast, the "ab*" pattern matches "a".

?

Matches the preceding item 0 or 1 time. For example, the "ab?" pattern matches "a" or "ab" but does not match "abbb".

|

Matches either the preceding expression or the following expression. Logical OR operator.

$

Matches the expression at the end of the input or line. For example, "ab$" matches "I took a cab" or "drab" but does not match "absolutely not".

^

Matches the expression at the beginning of the input or line. For example, "^ab" matches "absolutely not" or "abacuses are great!" but does not match "I took a cab" or "drab".

\

For characters that are usually treated as special. This indicates that the next character is literal and is not to be treated as a special character. For example, "\." means match the "." character and not just any character.

[ ]

A character set. Matches any one of the enclosed characters. You can specify a range of characters by using a hyphen. For example, [a-zA-Z] matches any letter of the alphabet.

[^ ]

An excluded character set. This is the opposite of []. If any of the characters inside the brackets exist, the regular expression match fails. You can specify a range of characters by using a hyphen. For example, [^a-zA-Z] ensures that none of the letters in the alphabet are present.

( )

A group expression. This groups an expression into an item that you can apply special characters to. For example, "a*(ba)+" matches "ba" "aba" or "ababa" but does not match "abbba" or "abaa"

 

 

 

jonjor