Extract String Value from
Variable
This task allows you to extract a part of a variable and save this part to a new variable.
Variable name
Select the variable you need to
use from the list. For some variables like DATE, you need to
manually enter the format.
Regex
To extract a substring from a variable, we
have to use regex grouping. The values of the match groups is
returned. See examples below.
The first subgroup is saved as variable taskTitle::Value1, second
as taskTitle::Value2 etc.
Examples:
1) Variable
value: 06-19-09 (some date)
Regex: ([0-9]{1,})
taskTitle::Value1
= 06
taskTitle::Value2 = 19
taskTitle::Value3 = 09
Explanation: ( ) is the grouping operator. [0-9] matches a
number. [0-9]{1,} matches 1 or more numbers and puts it into the
group.
2) Variable value: test12345test
Regex:
([0-9]+)
taskTitle::Value1= 12345
Explanation: ( )
is the grouping operator. [0-9] matches a number. [0-9]+ matches 1 or
more numbers and puts it into the group. This group of numbers 12345
is extracted as the result.
3) Variable value: 12345Test6789
Regex:
([0-9]{1,})[a-zA-Z]{1,}([0-9]{1,})
taskTitle::Value1 =
12345
taskTitle::Value2 = 6789
Explanation: [a-zA-Z]
finds any uppercase or lowercase letters. {1,} matches 1 or more.
i.e. 1 or more uppercase or lowercase letters. ( ) is the grouping
operator. [0-9] matches a number. [0-9]+ matches 1 or more numbers
and puts it into the group. This group of numbers 12345 is extracted
as the result.