egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

regexp

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
StaleJoke
Voice


Joined: 29 Nov 2005
Posts: 10

PostPosted: Wed May 03, 2006 7:52 pm    Post subject: regexp Reply with quote

Code:

set r [regexp -nocase -all {$t1|$t2} $arg]


Doesn't work. Any corrections need to be done ?
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed May 03, 2006 8:42 pm    Post subject: Reply with quote

$ has special meaning inside {} in regexp. Try "" instead {}.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Wed May 03, 2006 9:01 pm    Post subject: Reply with quote

Variables are not expanded inside of curly braces, you need to use double quotes as Sir_Fz suggested when using variables for matchin with regexp.
Back to top
View user's profile Send private message
avilon
Halfop


Joined: 13 Jul 2004
Posts: 64
Location: Germany

PostPosted: Thu May 04, 2006 11:54 am    Post subject: Reply with quote

Code:
set RE {$t1|$t2}

set r [regexp -nocase -all -- [subst -nocommands -nobackslashes $RE] $arg]
Back to top
View user's profile Send private message
StaleJoke
Voice


Joined: 29 Nov 2005
Posts: 10

PostPosted: Thu May 04, 2006 8:02 pm    Post subject: Reply with quote

Done.

Code:

set r [regexp -nocase -all -- [subst -nocommands -nobackslashes $RE] $arg]


But problem happens when it the var $RE is ) or a (
The error it spews out is

Tcl error [rep_fld]: couldn't compile regular expression pattern: parentheses () not balanced

Any suggestions ?
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu May 04, 2006 8:13 pm    Post subject: Reply with quote

Code:
set RE [string map {( \\( ) \\)} $RE]

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
StaleJoke
Voice


Joined: 29 Nov 2005
Posts: 10

PostPosted: Wed May 10, 2006 8:54 pm    Post subject: Reply with quote

On the same lines, if the bot encounters an astrix * as part of the word ( e.g. word* ) it gives me the error as:

Tcl error [repact_fld]: couldn't compile regular expression pattern: quantifier operand invalid
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed May 10, 2006 8:57 pm    Post subject: Reply with quote

Code:
set RE [string map {( \\( ) \\) * \\*} $RE]

You might want to add more special characters to this list.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber