There are 3 forms of string literals (more if you count interpolated strings and block quotes).
|without interpolation||with interpolation|
The q and Q forms allow newlines within the quote.
The q and Q forms allow other quote marks to be used. Valid quote mark pairs are shown below.
Using a block modifier after a q or Q token, separated by a colon, allows you to use block quotes with a specific marker. This is similar to a "HEREDOC."
This may also be used with regex literals.
The ending marker must be on a line of its own, with no trailing spaces. As of 0.9.3, leading spaces and tabs are allowed.
val .str = q:block BLOCK_STRING some multi-line string ... BLOCK_STRING
The line return after the opening marker and the line return before the ending marker are not part of the string.
A block modifier is always the last modifier on a literal.
String literals allow characters designated as "Graphic" by Unicode and ASCII space characters.
You can use an any modifier to allow any code point in a string or regex literal.
Regex literals also have their own modifiers.
The plain form and the q form for string literals interpret langur escape codes and the Q form does not.
Bare octal escape codes are not allowed. Use \oXXX instead.
Quote marks are not escaped by doubling, as I find that to be a confusing and inferior syntax.
|\" \' \/ \) \] \} \>||when otherwise used as a closing quote mark|
|\0||null (1 to 9 not defined)|
such as line feed or CR/LF
|\L||Unicode line separator|
|\P||Unicode paragraph separator|
|\xXX||2 digit hexadecimal code unit (00 to 7F)|
|\oXXX||3 digit octal code unit (000 to 177)|
|\uXXXX||4 digit hexadecimal code point|
|\UXXXXXXXX||8 digit hexadecimal code point|
You can use a w// or W// literal for a quoted word array, as a semantic convenience.
Besides using empty quote marks, you can use the ZLS token for an empty string (zero-length string).
|~ (tilde)||concatenate operator|
|x integer||string x integer (see below)|
The concatenation operator may be used between strings, or between a string and an integer (code point).
val .result = "A" ~ "B" # .result == "AB" val .result2 = "a" ~ 99 # .result2 == "ac"
You can also concatenate code points to generate to a string.
97 ~ 98 ~ 99 == "abc"
To repeat a string, use it with a multiplication operator and integer.
val .result = "A" x 4 # .result == "AAAA"
String multiplication, instead of throwing an exception, treats negative integers like 0.
Code point literals are specified with straight single quotes.
They are integers. There is no code point type.
Escape codes may be used in code point literals, unless they might be more than a single code point (no system newline \N escape).
|'\L'||Unicode line separator|
|'\uFEFF'||code point FEFF; same as 16xFEFF|
Bare code point literals (unescaped) allowed are the same as code points allowed in string literals.