String
Strings contain textual data. Strings do not have any specific meaning, which is to say that their contents are never interpreted in any way.
Defining String values
- Preprocessor:
- In the Step properties pane, under Properties, add or select a field.
- Specify the Type as String and set a default value as any text between quotes, followed by a semicolon, e.g.
"This is my text";
- Extraction:
- In the Data Model, select a field.
- On the Step properties pane, under Field Definition set the Type to String.
- JavaScript Expression: Set the desired value to any string between quotes. Example:
record.fields["countryOfOrigin"] = "Canada";
Building String values
String values can be made up of more than just a series of characters between quotes. Here are a few tips and tricks to build strings:
- Both single and double quotes can be used to surround strings and they will act in precisely the same manner. So, "this is a string" and 'this is a string' mean the same thing. However, it's useful to have both in order to remove the need for escaping characters. For instance, "I'm fine!" works, but 'I'm fine!' does not since only 'I' is properly interpreted. 'I\'m fine!' works (escaping the ' with a \).
- It is possible to put more than one string, as well as variables containing strings, by concatenating them with the + operator. For example,
"Hello " +
.sourceRecord.property.FirstName
+ ", nice to meet you!" - Adding more data to an existing string variable or field is possible using a combination of concatenation and assignment. For example, after the statements
var myVar = "Is this the real life";
, andmyVar += " or is this just fantasy?";
, the value ofmyVar
will be, obviously"Is this the real life or is this just fantasy?"
.
For more information on string variables, see quirksmode.org.