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.

Facts