mIRC Home    About    Download    Register    News    Help

Print Thread
#195892 05/03/08 02:28 PM
Joined: Mar 2007
Posts: 139
S
Solo1 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
Hi

I would like a regex to see if a string is in the format that is returned by $address(nick,2) and return true if it is.
example return true if *!*@user-irc.server.com

thanks in advance

Solo1 #195893 05/03/08 02:52 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
To do wildcard matches like that, you can use the ISWM comparison.


if (*!*@user-irc.server.com iswm $address(nick,2)) { ;do something }


-genius_at_work

Joined: Mar 2007
Posts: 139
S
Solo1 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
Hi genius_at_work
this won't help me as i will be comparing it to random strings. i need the regex to be able to look at any random string and if the string is in mIRC's format of $address($nick,2) (*!*@the-string.could.be.anything.com) it would return true.

I hope i made myself clearer.

Thanks again

Solo1 #195896 05/03/08 03:32 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I still don't think I follow completely.

Do you want to be able to tell if a string is:

Code:

[asterisk][exclamation mark][asterisk][AT symbol][some random characters]



If so,

$regex(%string,/^\*!\*@.+$/)

This should match the above description, with NOTHING before or after it.

-genius_at_work

Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
that would also return 1 for mask type 4 :p

a more accurate example would be /^\*!\*@[^*!@]+$/

there's even a non-regex involved method, check if $mask($replace(mask,*,a,?,1),2) == mask. not as strict as the first method since it requires the mask to be valid, still quite usable though


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
jaytea #195944 06/03/08 05:22 PM
Joined: Oct 2006
Posts: 166
B
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2006
Posts: 166
yo jaytea where u've been?


Kind Regards, blink
jaytea #195978 07/03/08 12:11 PM
Joined: Mar 2007
Posts: 139
S
Solo1 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
perfect just what i needed.


Link Copied to Clipboard