This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

backslashing

Old posts that have not been replied to for several years.
Locked
T
TomSommer

backslashing

Post by TomSommer »

I have a variable that contains ":)"

now I want to do a regexp match for this, like so
set test ":)"
regexp -nocase $test $string

But then I get "couldn't compile regular expression pattern: parentheses () not balanced"

SO, then i thought I wanted to escape ")", but is there a function for this... or something easier? thx
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You could write a function, but then you wouldn't be able to use any regexp special chars because they would all be escaped. That would make regexp totally useless... just use string match instead.

Change your code like this:

set test {:\)}
regexp -nocase $text $string
Locked