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.

regexp question

Old posts that have not been replied to for several years.
Locked
User avatar
droolin
Halfop
Posts: 64
Joined: Thu Jul 24, 2003 9:07 pm
Contact:

regexp question

Post by droolin »

Could someone provide me with an example of regexp using the regular expresion stored in a variable? I have alot of documentation on regular expresions, but I can't seem to find anything with the expresion you are trying to match against being contained in a variable.
Example of what Im trying to do:

Code: Select all

set FindThis "[A-Z][a-z]+_[0-9][0-9]"
regexp $FindThis $text
Im testing my regular expresions in tclsh. They work when I hard code them, but never work when I store them in a variable.
Any help would be greatly appriceated.

droolin
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Code: Select all

set FindThis {[A-Z][a-z]+_[0-9][0-9]}
regexp $FindThis $text 
User avatar
droolin
Halfop
Posts: 64
Joined: Thu Jul 24, 2003 9:07 pm
Contact:

hmmmm

Post by droolin »

ok, when I first testing. I was using a regular expresion that required escape charachters. and thats where I really had the problem.
Exanoke

Code: Select all

{\(Killed \Dabigun}
so, if I do the set like you showed. That will take the escape characters also?
And thank you very much, I would never have thought to set that variable that way.


droolin
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

if you work with { } you dont have to bother escape chars
(e.g : set x "he said \"blub\"" = set x {he said "blub"}
Locked