User Guide > Scripting > Script Operators > Concatenation (&) Operator
Was this helpful?
Concatenation (&) Operator
Use the concatenation operator to concatenate or merge data from two or more fields in the source file into a single field in the target file.
Best Practice — The + operator should not be used to concatenate strings because of potential ambiguities resulting from its use for addition.
Concatenate (&) Operator
 
Description
Concatenate two operands after coercing each operand to a string value
Syntax
result = operand1 & operand2
Remarks
The & operator creates a string result from its two operands. Numeric operands are first converted to string values. Null valued operands are treated as empty strings except in the case where both operands are Null. If both operands are Null, then the result of the operation is also Null.
Example
The following example uses the & operator to concatenate the contents of two fields with no space between the data.
FieldAt("/SOURCE/R1/Field12") & FieldAt("/SOURCE/R1/Field30")
The following example uses the & operator to concatenate the contents of three fields with a space between each piece of the data:
FieldAt("/SOURCE/R1/First Name") & " " & FieldAt("/SOURCE/R1/Middle Initial") & " " & FieldAt("/SOURCE/R1/Last Name")
The following example uses the & operator to concatenate a string of data to the end of the data in an existing field with a space between each piece of the data.
FieldAt("/SOURCE/R1/Field2") & " " & FieldAt("/SOURCE/R1/REGION")
The following example takes a 10-digit phone number from the ("Phone_Number") source field and converts it to a standard phone number format with dashes (such as 512-459-1308).
Left(FieldAt("/SOURCE/R1/Phone_Number"), 3) & "-" & Mid(FieldAt("/SOURCE/R1/Phone_Number"), 4,3) & "-" & Right(FieldAt("/SOURCE/R1/Phone_Number"),4)
Last modified date: 10/22/2024