Required output | Example Text Expression |
---|---|
Completed | "Completed" |
abc"def | To embed a quote mark:
This is different to regular expressions, in which a double-backslash is used to escape special characters. |
The account number ACC46242 failed | Generate a message including the current account number being processed, which is provided by _out.accountNumber:
|
This message is finished. |
|
Escaping Special Characters
When writing expressions you may need to enter a character that has special meaning. For example, a string could include a double-quote, but in the expression PhixFlow will read this as the end of the string. To tell PhixFlow to ignore a special character, you can use the backslash character.
You must use a backslast to escape any of the special characters listed in the table below.
Character | Type | Escape string |
---|---|---|
backspace | Represented As | "\b" |
Escaped | "\\\\b" | |
form feed | Represented As | "\f" |
Escaped | "\\\\f" | |
tab | Represented As | "\t" |
Escaped | "\\\\t" | |
carraige return | Represented As | "\r" |
Escaped | "\\\\r" | |
newline | Represented As | "\n" |
Escaped | "\\\\n" | |
backslash | Represented As |
|
Escaped | "\\\\\\\\" | |
double quote | Represented As | '"' |
Escaped | '\\\\"' |
Examples
Handling JSON data in PhixFlow often requires adding escape characters or removing characters that PhixFlow cannot recognise.
Some databases do not recognise 4-bit characters, such as emojis; see Database for recommended database configurations.
- Oracle database with the recommended configuration can store the full range of Unicode characters including 4-bit characters.
- MariaDB databases cannot store 4-bit characters. You will need to remove any invalid characters before writing to the database
Escaping Invalid Characters
If you are outputting stream data into JSON format, the data can include special characters that JSON will not accept. The following macro escapes these invalid characters.
do( $value = $args[1], $value = replaceAll( $value , "\b","\\\\b"), $value = replaceAll( $value , "\f","\\\\f"), $value = replaceAll( $value , "\t","\\\\t"), $value = replaceAll( $value , "\r","\\\\r"), $value = replaceAll( $value , "\n","\\\\n"), $value = replaceAll( $value , "\\\\","\\\\\\\\"), $value = replaceAll( $value , '"','\\\\"') )
Validating Data Imported Into PhixFlow
JSON data, like any imported data format, can include characters that cannot be written to a database that is using the UTF-8 character set. For example, 4-bit Emojis are not supported by UTF-8.
The following regular expression lists the characters expected in a JSON file and removes invalid characters from it.
replaceAll(JSON Code,"[^\\p{Space}0-9A-Za-z!:\\\"%&\\[*()\\],-/_\\\\{}\\.]","")
The backslash character escapes special characters such as [] , .
and \