String Functions#
fn.is_string : Return true or false if the parameter is a string or not.
fn.index : Return the i’th item of an iterable, such as a list or string.
Example
Output
{{ fn.index 'foo bar baz',5 }}
'b'
fn.mask : Return a mask of (length + modifier) instances of char.
Example
Output
{{ fn.mask X,2,3 }}
XXXXXX
fn.length : Return the length of a string.
Example
Output
{{ fn.length This is a valid string }}
22
fn.split : Split a string by delimiter, returning a list.
Example
Output
{# fn.split foo:bar:baz,: #}
['foo', 'bar', 'baz']
fn.join : Join a string by delimiter. If no delimiter is provided, the list is returned as a single string.
Example
Output
{{ fn.join 1234,: }} {{ fn.join 1234 }}
1:2:3:4 1234
fn.title : Return a string in title case.
Example
Output
{{ fn.title 'foo bar baz' }}
'Foo Bar Baz'
fn.upper : Return an uppercase version of the input string.
Example
Output
{{ fn.upper somevalue }}
SOMEVALUE
fn.lower : Return a lower case version of the input string.
Example
Output
{{ fn.lower SOMEVALUE }}
somevalue
fn.contains : Return true or false if string is contained in another.
Example
Output
{{ fn.contains needle,haystack }} {{ fn.contains hay,haystack }} (( fn.contains Kit,1234 Kit Creek == True ))
false true true
fn.sub_string : Return the substring of a string from a start to an end position.
Example
Output
{{ fn.sub_string haystack,0,2 }} {{ fn.sub_string haystack,7,7 }}
hay k
fn.containsIgnoreCase : Return true or false if string is contained in upper- or lower case.
Example
Output
{{ fn.containsIgnoreCase aaa,bbbaAaccc }}
true
Example
Output
Input
{"input": {"UserName": "[email protected]"}}
Function call
((fn.containsIgnoreCase Host,input.UserName == True)) <{{input.UserName}}><>
fn.containsStartsWith : Return true or false if source string is the start of target string.
Example
Output
{{ fn.containsStartsWith aaa,aaaffccffdd }}
true
fn.containsStartOf : Return true or false if start of source string is target string.
Example
Output
{{ fn.containsStartOf ffnnccgg,ffnn }}
true
fn.regex_match : Return true or false if the regular expression matches the start of target string.
Example
Output
{{ fn.regex_match a,ab }}
true
{{ fn.regex_match a$,ab }}
false
{{ fn.regex_match \d+,abc555 }}
false
{{ fn.regex_match \d+,555abc }}
true
fn.isexactly : Return true or false if source string is exactly the same as target string.
Example
Output
{{ fn.isexactly source1,source1 }}
true
fn.replace : Replace target substring for source substring in source string.
Example
Output
Note: no spaces between commas.
{{ fn.replace dddddAAAc,AAA,FFF }}
dddddFFFc
fn.validate_name : Return true or false if the string as well as its stripped content (default white space removed) exists, i.e. is then more than 0 characters.
Example
Output
{{ fn.validate_name }} {{ fn.validate_name a }}
false true
fn.fix_non_ascii : Given a string containing non-ASCII characters, this function applies 3 steps of processing and returns a string with all non-ASCII characters mapped to ASCII characters.
The first step can be controlled by the optional “from” and “to” characters parameter pair that return a string with “from” characters replaced with “to” characters. This allows for control over the replacement.
The 3 steps are carried out in the following sequence:
Map characters in the given string by using the corresponding characters in the “<from>,<to>” string parameter pair.
If the parameters are not added, this step is skipped.
If it is required to have control over the mapping of non “accented” characters (see step 2), then this default mapping can be done by providing the “<from>,<to>” string parameter pair.
Map all “accented” (accent, circumflex, diaeresis, etc.) non-ASCII characters to ASCII characters.
Map all remaining non-ASCII characters with the underscore character:
_
.
For example:
string =
Ŧest Nón Asciï
<from>,<to> =
ï,G
result =
_est Non AsciG
step 1: from =
ï
is replaced with to =G
.step 2: accented
ó
is replaced witho
step 3:
Ŧ
is a remaining non-ASCII character and replaced with_
.In the above example, the
Ŧ
is not an “accented” character and was therefore not mapped in step 2. If the preference is not to have theŦ
character mapped to the underscore character, then this character could be included in the “<from>,<to>” string parameter pair.Example
Output
{{ fn.fix_non_ascii 'Têst Nón Asciïæ mapping',sæ,Ga }} {{ fn.fix_non_ascii 'Ŧest Nón Asciï' }}
'TeGt Non AGciia mapping' '_est Non Ascii'
fn.fix_username : Given a string of characters, return the string with a replacement character:
-
for any character not in the following range:a-zA-Z0-9._-
.A Unified CM Remote Destination name is an example where such a string is required.
Example
Output
{{ fn.fix_username O'Reilly }}
O-Reilly