Using Quotes Correctly

Specifying literal string values within New Field code or within Filters is a common need.  Below are some rules and tricks to ensuring you do it correctly.


Use Single Quotes to Delimit Literal Strings in Your Code

Literal string values that you need to reference in your LityxIQ new field or filter code should be delimited with single quotes on either side.  For example, SUBSTRING('ABCD', 1, 2).

If you require a single quote to be within your literal string, you can "double it up", meaning put two single quotes in a row inside of the single-quoted string.  For example:

SUBSTRING( 'ABC''D', 1, 2)

Note that the '' inside the above code is not a double-quote character, but two single-quote characters in a row.  This is valid code, and the string will be evaluated as ABC'D before the substring operation is executed.


Taking Care Using Double Quotes

Double quoting strings is common in many languages, and therefore LityxIQ will allow you to delimit literal string values with double quotes as well.  So, the code:


will work fine, and essentially LityxIQ translates a double quote into a single quote behind the scenes to make this work as you'd expect.

However, because of this, creating a literal string value that has an actual double quote as part of the string is a little trickier.  To create a string that has an embedded double quote, specify three (yes 3) consecutive double quotes to represent one double quote.  For example:

SUBSTRING( 'ABC"""D', 1, 2)

will interpret the string you are working with as: ABC"D.  That is, the letters ABC followed by a double quote, followed by the letter D.

You can also specify:

SUBSTRING("ABC"""D", 1, 2)

to get the same result. That is, you can delimit the string with double quotes on either side, then use the tripled-up double quotes within the string.