regsub
regsub ?-option ...? exp string subSpec ?varName?
Replaces the matches of exp in string with subSpec, and gives the new string. In subSpec, & and \0 are the match, and \1 to \9 are the groups. With varName, it puts the string in the variable and gives the count of replacements.
Options
| Option | What it does |
|---|---|
-all |
Replaces each match. Without it, only the first. |
-nocase |
Matches letters with no case. |
-start INDEX |
Starts the search at INDEX. |
Examples
A click on an example runs it in the shell of the page.
regsub -all {\s+} "a b c" " ":a b cregsub -all {#(\w+)} "x #a #b" {<\1>}:x <a> <b>
Facts
- Capability: none.
- Compute cost: one compute unit for the call, and more for the commands that it runs.