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.

another regexp problem ....

Help for those learning Tcl or writing their own scripts.
Post Reply
w
wubmerlin
Voice
Posts: 6
Joined: Sun Nov 04, 2007 11:50 am

another regexp problem ....

Post by wubmerlin »

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: Select all

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"
                }
        }
}
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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

Try something like this instead:

Code: Select all

...
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: Select all

set test [list roger john frank]
NML_375
w
wubmerlin
Voice
Posts: 6
Joined: Sun Nov 04, 2007 11:50 am

Post by wubmerlin »

:D thanks alot ! :D
Post Reply