mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2003
Posts: 261
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
A buddy and me are working on this little script, and we need to have like all url's that are found be changed.

every www.blah.com changed to www dot blah dot com.
http://www.blah.com changed to http://www dot blah dot com.

$replace just won't do as it replaces every occurance. We need some magic.

Been playing with this using different regex stuff (we are new to this regex) and coming up short changed:
Code:
alias pim {
  var %text = http://www.cow.com :: www.cow.com :: www.com :: thewww.cow.com :: thewww.com
  return $regsubex(%text,/\b(www\.)\b/ig,www dot $+ $chr(32))
}

Which results in:
http://www dot blah.com :: www dot blah.com :: www dot com :: thewww.blah.com :: thewww.com

but we want:

http://www dot blah dot com :: www dot blah dot com :: www.com :: thewww.blah.com :: thewww.com

We'd actually like it to find any .net .org etc... stuff.
Any help appreciated.

#158719 08/09/06 05:51 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
±

#158720 08/09/06 06:19 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
What's that supposed to mean?


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#158721 08/09/06 07:03 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
I had clicked to reply to my own post with some code to display. But didn't think it was nessessary after my post. and Since there's no delete post option for accidental posts I just changed it to that char.

#158722 08/09/06 07:10 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
You can go to edit, then "delete this post"

#158723 08/09/06 07:13 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
lol man do I feel like an idiot, thanks. Well I'm going to leave it up just for a laugh smile.

Joined: Sep 2003
Posts: 261
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
So I guess it's really hard to do huh? frown

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
www.com is a valid hostname (even points to a real website). If there's no particular reason that it shouldn't match, the alias below should do the job:

/alias pim return $regsubex($1,/(?<=^| )((?:(?:http|ftp|irc|news|gopher)://)?(?:[a-z\d](?:[a-z\d-]*[a-z\d])?\.)+[a-z]{2,}(?::\d{1,5})?)(/\S*|(?= |$))/gi,$replace(\1,.," dot ",",) $+ \2)

Last edited by qwerty; 08/09/06 11:59 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Sep 2003
Posts: 261
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
I don't know how to explain it frown.
I want like:
www.blah.com to be www dot blah dot com

www.com was an example to make sure that it didn't turn out to be www dot com. To see if it would ignore it like it's suppose to.

Say someone types in the chat "hey everyone go to www.blah.com"
I want it to instead show "hey everyone go to www dot blah dot com"

And say someone types in the chat "hey everyone go to www.com"
I want it to instead show "hey everyone go to www.com"
not "hey everyone go to www dot com"

Same goes for http://www.blah.com i want http://www dot blah dot com.

It's for agenting, agent tends to ignore the .'s when speaking thinking they are periods and not dots.
So when agent speaks we want to hear dot and not "silence"

Joined: Sep 2003
Posts: 261
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
whoa, heh that's some text you got going on. frown I wish like, there was actual tutorials for regex, tutorials that actually translate to english what all that means. That is intresting how it turns out though.
Code:
http://www dot cow dot com :: www dot cow dot com :: www dot com :: thewww dot cow dot com :: thewww dot com
but it's not:
http://www dot cow dot com :: www dot cow dot com :: www.com :: thewww.cow.com :: thewww.com

some better examples:
(if what I'm wanting works when it's all done)

This is a url http colon //www dot awebsite dot com. Everyone go to it.
This is a url www dot awebsite dot com. Everyone go to it.
This is a url www.awebsite. Everyone go to it.
This is a urlwww.awebsite.com. Everyone go to it.
This is a urlwww.com. Everyone go to it.

thanks anyways frown I've bothered enough. It must be like tough cuz, I can't really explain what I'm looking for. I mean I know what I want to be returned, but I just can't explain it. Sorry to of taken up so much of your time frown. Thanks again.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
That's a bit of AI you want there smile Take for example this:

This is a urlwww.awebsite.com. Everyone go to it.

How would regex recognize that this isn't a valid url? You could make it reject anything that doesn't start with "www." but that's too much; you'd miss addresses like msdn.microsoft.com (basically any address that doesn't start with www).

Another case that I'm not sure you clarified is this:

Everybody go to <a href="urlhttp://www.awebsite.com" target="_blank">urlhttp://www.awebsite.com</a>

Should that be considered a valid url?


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Sep 2003
Posts: 261
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
Yeah, i seem to want the impossible. www. was just for test purposes, when it was done i was going to implement a way around that. But that is if I could ever master regex in 24 hours. frown I suppose id more than likely just leave it to http://something.this.that to keep it simple. have it search for just http://*.*.* and replace all occurances with http colon //* dot * dot *. I've seen some regex in action on other languages, and it can do multiple search and replace perameters I know it. But I dunno about mirc's version of regex if that's possible frown. Anyway, thanks for your help and suggestions, seems I needed something that wasn't possible yet.


Link Copied to Clipboard