From b6a53d878ee34de3028b21d34d186112be839f75 Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@gmail.com> Date: Tue, 28 Nov 2023 17:36:29 +0100 Subject: [PATCH] docs(templates): `replace` helper uses its argument as a regex (#26014) --- docs/usage/templates.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/usage/templates.md b/docs/usage/templates.md index 318a416169..e72e718257 100644 --- a/docs/usage/templates.md +++ b/docs/usage/templates.md @@ -61,12 +61,12 @@ Read the [MDN Web Docs, decodeURIComponent()](https://developer.mozilla.org/en-U ### replace -The `replace` helper replaces _all_ found strings with the replacement string. +The `replace` helper replaces _all_ found strings matching the given regex with the replacement string. If you want to replace some characters in a string, use the built-in function `replace` like this: -`{{{replace 'github.com' 'ghc' depName}}}` +`{{{replace '[a-z]+\.github\.com' 'ghc' depName}}}` -In the example above all matches of `github.com` will be replaced by `ghc` in `depName`. +In the example above all matches of the regex `[a-z]+\.github\.com` will be replaced by `ghc` in `depName`. Read the [MDN Web Docs, String.prototype.replace()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) to learn more. -- GitLab