From ac8cd618b4222345c387303d1e53d9f85c221b3b Mon Sep 17 00:00:00 2001 From: Ignatius Bagus Date: Sat, 10 Jul 2021 11:16:37 +0700 Subject: [PATCH] docs: mention usage of regexp literal in text expressions (#5640) --- site/content/docs/02-template-syntax.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/site/content/docs/02-template-syntax.md b/site/content/docs/02-template-syntax.md index 923616ccae..ca0c1d4993 100644 --- a/site/content/docs/02-template-syntax.md +++ b/site/content/docs/02-template-syntax.md @@ -136,11 +136,14 @@ An element or component can have multiple spread attributes, interspersed with r Text can also contain JavaScript expressions: +> If you're using a regular expression (`RegExp`) [literal notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#literal_notation_and_constructor), you'll need to wrap it in parentheses. + ```sv

Hello {name}!

{a} + {b} = {a + b}.

-``` +
{(/^[A-Za-z ]+$/).test(value) ? x : y}
+``` ### Comments