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 

another regexp problem ....

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


Joined: 04 Nov 2007
Posts: 6

PostPosted: Sat Dec 15, 2007 6:09 pm    Post subject: another regexp problem .... Reply with quote

HELP ! i want to scan email address to know if it contain _something_ or -something_ ......
Ex: !vlaid test_roger_email@testmail.com

But i cant get it to work.
Thanks for your help !

Code:

proc test { nick uhost hand chan arg } {
        set text [lindex $arg 0]
        set check [lindex $arg 2]
        set test "roger john frank"
        foreach x $test {
                if {[regexp -nocase {[-_]$x[_-]} $text] != 0} {
                        putserv "PRIVMSG $chan :$text is a valid email"
                } else {
                        putserv "PRIVMSG $chan :$text is invalid"
                }
        }
}
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Dec 15, 2007 7:45 pm    Post subject: Reply with quote

Using {} prevent the parsing of variables, brackets and such...

Try something like this instead:
Code:
...
regexp -nocase "\[-_\]$x\[-_\]" $text
...


Also, your code is flawed, in that it uses lindex on a string, when it should only be used on proper lists. Please considder splitting $arg before using lindex...

Finally, you really should be creating your list of names properly, that is, something like this:
Code:
set test [list roger john frank]

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
wubmerlin
Voice


Joined: 04 Nov 2007
Posts: 6

PostPosted: Sat Dec 15, 2007 8:59 pm    Post subject: Reply with quote

Very Happy thanks alot ! Very Happy
Back to top
View user's profile Send private message
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