@@ -20,6 +20,18 @@ The component supports:
20
20
* **booleans ** - ``true `` and ``false ``
21
21
* **null ** - ``null ``
22
22
23
+ .. caution ::
24
+
25
+ A backslash (``\ ``) must be escaped by 4 backslashes (``\\\\ ``) in a string
26
+ and 8 backslashes (``\\\\\\\\ ``) in a regex::
27
+
28
+ echo $language->evaluate('"\\\\"'); // prints \
29
+ $language->evaluate('"a\\\\b" matches "/^a\\\\\\\\b$/"'); // returns true
30
+
31
+ Control characters (e.g. ``\n ``) in expressions are replaced with
32
+ whitespace. To avoid this, escape the sequence with a single backslash
33
+ (e.g. ``\\n ``).
34
+
23
35
.. _component-expression-objects :
24
36
25
37
Working with Objects
@@ -181,28 +193,6 @@ Comparison Operators
181
193
You must use parenthesis because the unary operator ``not `` has precedence
182
194
over the binary operator ``matches ``.
183
195
184
- A backslash(``\ ``) must be escaped by 4 backslashes(``\\\\ ``) in a string and
185
- 8 backslashes(``\\\\\\\\ ``) in a regex::
186
-
187
- $language->evaluate('"\\\\"');
188
- // returns \
189
-
190
- $language->evaluate('"a\\\\b" matches "/^a\\\\\\\\b$/"');
191
- // returns true
192
-
193
- Control characters must be defined as the escaped form of their escape sequences.
194
- Otherwise, they will be replaced by spaces and ignored::
195
-
196
- $language->evaluate('"a\nb"');
197
- // returns a b
198
-
199
- $language->evaluate('"a\\nb"');
200
- // returns a\nb
201
-
202
- This is because the backslashes in a string will be stripped by the
203
- ``stripcslashes() `` function and the stripped slashes in a regex will be
204
- stripped again by the regex engine.
205
-
206
196
Examples::
207
197
208
198
$ret1 = $language->evaluate(
0 commit comments