Thursday, July 12, 2012

regsub Command


Regsub Usage

Replaces a value with a given value

Syntax:
regsub “<actual value in the string>”  $string “<value to replace>” <newString>


Example:

set string "My name is Kavitha"

regsub "Kavitha" $string "Mythri" name2
puts "$name2"

Output

My name is Mythri

1 comment:

  1. Nice explaination .. Also can you tell about how to do same if i want to replace string in file

    ReplyDelete