Clarify replace() syntax
This commit is contained in:
parent
31dfa97e3d
commit
a929b4825a
1 changed files with 9 additions and 3 deletions
|
|
@ -75,9 +75,15 @@ Replaces each match of Regex in the string with `sub`.
|
|||
If `sub` is a `proc (RegexMatch): string`, then it is executed with each match
|
||||
and the return value is the replacement value.
|
||||
|
||||
If `sub` is a string, then each match is replaced with that string, where the
|
||||
captures are accessable as `$1`, `$2`, and so on. A literal `$` can be added by
|
||||
doubling up like so: `$$`.
|
||||
If `sub` is a string, the syntax is as follows:
|
||||
|
||||
- `$$` - literal `$`
|
||||
- `$123` - capture number `123`
|
||||
- `$foo` - named capture `foo`
|
||||
- `${foo}` - same as above
|
||||
- `$1$#` - first and second captures
|
||||
- `$#` - first capture
|
||||
- `$0` - full match
|
||||
|
||||
[[proc-escapere]]
|
||||
==== escapeRe(string): string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue