Skip to content

Commit

Permalink
docs(templates): replace helper uses its argument as a regex (#26014)
Browse files Browse the repository at this point in the history
  • Loading branch information
erdnaxeli committed Nov 28, 2023
1 parent 044bf9f commit b6a53d8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/usage/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit b6a53d8

Please sign in to comment.