Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

including a "[" in a regexp

Status
Not open for further replies.

bradfisher133

Technical User
May 16, 2003
1
US
Hello All,

I want to search a string containing brackets or braces.
How do I escape brackets or braces in a regexp command?
For example, consider the following illegal regexp command:

set i 5
regexp "path($i)" "path(5)"

I want the braces to be viewed as a character, not a grouping device.

thanks
--Brad

 
Not sure what you are doing with that regexp call but usually when i want tcl to ignore grouping devices i put a \ just before any characters that I want ignored. For instance

>set i 5
>puts $i
5
>puts \$i
$i

and it works for () {} [] just make sure you get the opening and closing braces/paren/brackets
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top