blob: cb0c903f386a1055bd1b60707ea537e985617217 [file] [log] [blame] [view]
Marcel van Lohuizen0117d902019-02-21 23:55:39 +01001[TOC](Readme.md) [Prev](stringlit.md) [Next](bytes.md)
2
3_JSON Sugar and other Goodness_
4
5# "Raw" Strings
6
7CUE does not support raw strings in the strictest sense.
8Instead it allows modifying the escape delimiter by requiring
9an arbitrary number of hash `#` signs after the backslash by
10enclosing a string literal in an equal number of hash signs on either end.
11
12This works for normal and interpolated strings.
13Quotes do not have to be escaped in such strings.
14
15<!-- CUE editor -->
Marcel van Lohuizenf0c94042019-02-22 22:46:37 +010016_stringraw.cue:_
Marcel van Lohuizen0117d902019-02-21 23:55:39 +010017```
18msg1: #"The sequence "\U0001F604" renders as \#U0001F604."#
19
20msg2: ##"""
21 A regular expression can conveniently be written as:
22
23 #"\d{3}"#
24
Marcel van Lohuizenf0c94042019-02-22 22:46:37 +010025 This construct works for bytes, strings and their
26 multi-line variants.
Marcel van Lohuizen0117d902019-02-21 23:55:39 +010027 """##
28```
29
30<!-- JSON result -->
Marcel van Lohuizenf0c94042019-02-22 22:46:37 +010031`$ cue eval stringraw.cue`
Tarun Gupta Akiralabb2b6512019-06-03 13:24:12 +000032```
Marcel van Lohuizen0117d902019-02-21 23:55:39 +010033{
34 msg1: "The sequence \"\\U0001F604\" renders as 😄."
35 msg2: """
36 A regular expression can conveniently be written as:
37
38 #\"\\d{3}\"#
39
Marcel van Lohuizenf0c94042019-02-22 22:46:37 +010040 This construct works for bytes, strings and their
41 multi-line variants.
Marcel van Lohuizen0117d902019-02-21 23:55:39 +010042 """
43}
44```