Name

regsub

regsub [options] exp string subSpec varName

Match regular expression exp against string string, making replacements defined by subSpec, and store the result in variable varName.

Options

-all

Replace all matching expressions in the string.

-nocase

Ignore case in pattern matching.

- -

Marks the end of options.

Example

regsub {[0-9]} a1b2c3 {#} result
    set result
    a#b2c3
    regsub -all< {[0-9]} a1b2c3 {#} result
    set result
    a#b#c#

Get Tcl/Tk in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.