Using a Mask Transform
You can use the Transformer stage to apply a mask transform to a field. A mask transform applies characters to a field, or removes characters from a field, using a specified pattern. For example, using a mask transform you could format a string of numbers like 8003685806 into a phone number like this: (800) 368 5806.
- In Spectrum Enterprise Designer, drag a Transformer stage to the canvas and connect it in the desired location.
- Double-click the Transformer stage.
- Click Add.
- Expand Formatting and select Mask.
-
Select the type of mask you want to use.
- Apply
- Adds characters to a field to form the string into a new pattern.
- Remove
- Extracts a pattern of characters from a string.
-
In the Mask string field, specify the pattern you want to use when either adding characters or removing characters.
There are two types of characters you use when specifying the mask string: literal characters and mask characters.
Literal characters represent actual characters that are present in the string. When a remove mask is used, the input character must match the literal character exactly. If that is the case, then they will be removed from the input. Similarly, the literal characters will be added to the input in the position indicated by the mask definition when the apply mask is used.
The other type of character you can use in a mask string is a mask character. A mask character indicates the type of character that can be in a particular location of the input string. For example, if you have an input where the first character is a number, the first mask character needs to be
#
. Anything in the input that matches this mask character will be kept in the output.The table below lists the mask characters you can use in the Mask string field:
Table 1. Mask Characters Character
Definition
#
Any number.
'
Escape character, used to escape any of the special formatting characters.
U
Any character. All lowercase letters are mapped to upper case.
L
Any character. All upper case letters are mapped to lower case.
A
Any character or number.
?
Any character.
*
Anything.
H
Any hex character (0-9, a-f or A-F).
- Click Add.
- Click OK.
Mask Transform Examples
This is an apply mask that applies formatting to a string. Because "(" and ")" and <space> are literals, they will be added to the output. All the numbers will be kept because # is a mask character.
Input: 8003685806
Mask string: (###) ### ####
Output: (800) 368 5806
This remove mask example omits the dash in the ZIP Code.
Input: 60510-1135
Mask string: *****-****
Output: 605101135