|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
How come i cant get this to react on unreal:// ? I have added it as hotlink, how ever the script dosent underline it as it should, do i miss something here?
alias urltheme {
var %line = $1-
if ($regex(%line,/(\b(www.?\.|https?:\/\/|ftp:\/\/|unreal://\/\/).)/i)) {
var %x = 1
while (%x <= $numtok(%line,32)) {
if ($regex($gettok(%line,%x,32),/(\b(www.?\.|https?:\/\/|ftp:\/\/|unreal://\/\/).)/i)) {
var %l2 = $+($clr($theme_color(urls)),$chr(31),$gettok(%line,%x,32),$chr(31),$clr)
%line = $puttok(%line,%l2,%x,32)
}
inc %x
}
}
return %line
}
$theme_color(urls) returns the color of the text i want to echo, in my case 02..
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Jun 2007
Posts: 933
Hoopy frood
|
Hoopy frood
Joined: Jun 2007
Posts: 933 |
Errrr....
$regex(%line,/(\b(www.?\.|https?:\/\/|ftp:\/\/|unreal://\/\/).)/i)
You escape the slashes in https:// and ftp:// but not in [url=unreal://.][url=unreal://.][url=unreal://.]unreal://.[/url][/url][/url] Remove the first two slashes, which I assume you forgot to delete.
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
i forgot that one, but still no luck, i wont get the script to trigger on it
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Aug 2005
Posts: 525
Fjord artisan
|
Fjord artisan
Joined: Aug 2005
Posts: 525 |
Post deleted by schaefer31
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
i tested your code, but the only thing i got was that the color for it was f*ed up, and no reaction on unreal:, dunno why it's so hard to get it to work on just that one, dont know if it's cos it's not a default link in mirc, www - http - ftp do mirc it self react on, but unreal is a hotlink i created.. ;--------------- EDIT the code i trying to learn from can be found http://script.quakenet.org/wiki/How_to_make_your_own_theme since im new to $regex i cant solve it, how ever i trying to learn it. Any help would be usefull
Last edited by sparta; 19/06/07 10:40 AM.
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Aug 2005
Posts: 525
Fjord artisan
|
Fjord artisan
Joined: Aug 2005
Posts: 525 |
I don't know why you seem to have trouble triggering on unreal://, it works as expected for me. Actually you can just use $regsubex instead of looping like you are. mIRC 6.17 or later required, which I assume you're using. Try this, I used only simple underline replacement as a test since I don't know what your custom identifiers do. alias urltheme {
return $regsubex($1,/((?:(?:unreal|ftp|https?):\/\/|www\.)\S+)/Sgi,$+(,\t,))
} //echo -ag $urltheme(abc http://mirc.com def https://mirc.com ghi ftp://mirc.com jkl [url=unreal://m.i.r.c][url=unreal://m.i.r.c][url=unreal://m.i.r.c]unreal://m.i.r.c[/url][/url][/url] mno www.mirc.com) returns abc http://mirc.com def https://mirc.com ghi ftp://mirc.com jkl [url=unreal://m.i.r.c][url=unreal://m.i.r.c][url=unreal://m.i.r.c]unreal://m.i.r.c[/url][/url][/url] mno www.mirc.comWorks as expected. And here's the same code using your identifiers: alias urltheme {
return $regsubex($1,/((?:(?:unreal|ftp|https?):\/\/|www\.)\S+)/Sgi,$+($clr($theme_color(urls)),$chr(31),\t,$chr(31),$clr))
}
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
thanx for your help, i trying to learn, i will look at your code, then see if i can understand what everything is doing
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: Apr 2003
Posts: 342
Fjord artisan
|
Fjord artisan
Joined: Apr 2003
Posts: 342 |
thanx for your help, i trying to learn, i will look at your code, then see if i can understand what everything is doing I'd use... $regsubex($1,/((?:(?:[a-zA-Z0-9]*?):\/\/|www\.)\S+)/Sgi,$+(,\t,)) THough i would really rather not use regular expressions for this. Rather evalutate the line with a rather complex loop that advances one character every interation.
Beware of MeStinkBAD! He knows more than he actually does!
|
|
|
|
Joined: Aug 2005
Posts: 525
Fjord artisan
|
Fjord artisan
Joined: Aug 2005
Posts: 525 |
No need to over complicate things. a-zA-Z0-9 is effectively the same as using \w (effectively because \w also includes underscores, shouldn't be a problem). a-zA-Z is not necessary in this case either since the "i" modifier is used, just a-z or A-Z will do, don't need both. Also using *? here will cause it to underline even if no protocol is specified, in which case I believe it shouldn't. Better to use "+" (1 or more chars). You can also drop the inner most set of grouping brackets, since you're no longer specifying alternations. alias urltheme return $regsubex($1,/((?:\w+:\/\/|www\.)\S+)/Sgi,$+($clr($theme_color(link)),$chr(31),\t,$chr(31),$clr)) Although personally, I'd rather just worry about common protocols.
|
|
|
|
Joined: Apr 2004
Posts: 759
Hoopy frood
|
Hoopy frood
Joined: Apr 2004
Posts: 759 |
THough i would really rather not use regular expressions for this. Rather evalutate the line with a rather complex loop that advances one character every interation.
how do you think regular expressions are processed ? :P
$maybe
|
|
|
|
|