mIRC Home    About    Download    Register    News    Help

Print Thread
#85873 07/06/04 09:26 PM
Joined: Jun 2003
Posts: 114
T
Thray Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Jun 2003
Posts: 114
As I've previously mentioned in another post.. Regexes blow my mind. Not good at em.

I was trying to make one to match an email addy and came up with:
^[A-Za-z0-9_\.-]+@[A-Za-z0-9_\.-]+[A-Za-z0-9_][A-Za-z0-9_]$
Now, this is pretty basic stuff, right? I mean, this particular use of a regex. But I can't figure it out.

Oddly enough, it doesn't appear to match email addresses at all! It does.. weird matches. For example, if the letter 'c' is in it, it is always false.

Can anyone please explain what I'm doing wrong?


-------------
I am the self-appointed God of needlessly complex mIRCscript.
#85874 07/06/04 10:19 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Google gives this: ^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$

Also: ^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z0-9._%-]{2,4}$
and even ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$ if you want to allow for ip addresses...

You'll have to put them in a %var first, just putting the above in a $regex will parse incorrectly.

#85875 07/06/04 10:36 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I use this:
Code:
alias isemail var %a = /^[-.\w]+@(?:[a-z\d](?:[-a-z\d]*[a-z\d])?\.)+[a-z]{2,}$/i | return $regex($1,%a)
The hostname matching part is (hopefully) 100% accurate, unlike Google's regex.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard