| View previous topic :: View next topic |
| Author |
Message |
wubmerlin Voice
Joined: 04 Nov 2007 Posts: 6
|
Posted: Sat Dec 15, 2007 6:09 pm Post subject: another regexp problem .... |
|
|
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Dec 15, 2007 7:45 pm Post subject: |
|
|
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 |
|
 |
wubmerlin Voice
Joined: 04 Nov 2007 Posts: 6
|
Posted: Sat Dec 15, 2007 8:59 pm Post subject: |
|
|
thanks alot !  |
|
| Back to top |
|
 |
|