mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2007
Posts: 21
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2007
Posts: 21
Hey,

I have this code that "arrives" 1 line at a time.

Code:
<a href='http://tehclan.com/forum/index.php?showuser=51379' title='11:00 AM'><span style='color:orange'>Ash[numbers]_NM</span></a>,
<a href='http://tehclan.com/forum/index.php?showuser=49877' title='10:59 AM'><span style='color:#000000'><img src='http://tehclan.com/forum/rankicons/staff.gif' border='0'/>Egekalaycan</span></a>,
<a href='http://tehclan.com/forum/index.php?showuser=19999' title='10:54 AM'><span style='color:#6e2de4'><img src='http://tehclan.com/forum/rankicons/staff.gif' border='0'/>Ash44455666</span></a>,
<a href='http://tehclan.com/forum/index.php?showuser=44984' title='11:00 AM'><span style='color:#4C7FB1'>Rikieman1</span></a>,
<a href='http://tehclan.com/forum/index.php?showuser=50689' title='11:00 AM'><span style='color:#4C7FB1'>Killharry1</span></a>,
<a href='http://tehclan.com/forum/index.php?showuser=24641' title='10:49 AM'><span style='color:#4C7FB1'>jaguar838</span></a>,
MSN.com<br /><br />


I thought it wouldn't be too much of an issue; I wrote up this regular expression to get the information I need when those particular lines arrive (by the way, the number of the lines is never (guaranteed to be) the same, and the names will (usually) be different).

Code:
\d+? (?:AM|PM)'>(.+?)<\/a>


And so, when the line arrives, I would get everything between the end of the <a> tag to the </a> tag, then I would remove the remaining html using an alias I got from the net.

Thing is, it doesn't work at all, and every single variation of it that I could think of hasn't worked. In fact, this is the most recent "version" of it, whereas the original was much more complex, so much so that I wouldn't have needed any post-editing to have the name I want.

Thanks in advance; I've managed to accomplish so much to this point without actually getting any assistance (learning via google searches and this webpage), I can't believe I can't get something this simple to work. >.<

Also, since it may come in handy to others, I use this site to help me write regular expressions. I also learned a bunch from it. It isn't perfect in regards to mIRC Scripting, but it really helps nonetheless.

http://gskinner.com/RegExr/

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
I think you're making this too difficult.
Code:
$regex(%line,/M'>(.+)<\/a>/)

That would suffice, imo. Then you can call your desired bit with...
Code:
$regml(1)

I expect you want something more specific than the whole <span> section though?

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Hm, which part won't work for you?
Code:
alias regtest {
  var %text = <a href='http://tehclan.com/forum/index.php?showuser=19999' title='10:54 AM'><span style='color:#6e2de4'><img src='http://tehclan.com/forum/rankicons/staff.gif' border='0'/>Ash44455666</span></a>,
  var %regex = \d+? (?:AM|PM)'>(.+?)<\/a>

  if ($regex(%text,%regex)) { echo -a Match: $regml(1) }
}
...works for me with your example lines. So does:
var %regex = /\d{2}:\d{2} [AP]M'>(.+?)<\/a>/
var %regex = /<a href=\S+ title='\d{2}:\d{2} [AP]M'>(.+?)<\/a>/
etc (I don't know how "exclusive" matching has to be. The simplier the better).

Joined: Aug 2007
Posts: 21
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2007
Posts: 21
...
;_;

I found the problem.

Here's the actual code I have at the moment (that's relevant).

Code:
if (%gActiveMembers == true) {
  if ($regex(%tmp,/\d{2}:\d{2} [AP]M'>(.+?)<\/a>/)) {
    aline @tehclan Got Active Member: $htmlfree($regml(1))
  }
}

A previous if statement of similar case was for the variable "%gActiveMembersTypes". Problem was, in that same if statement (it was using regex as well to find how many guests, members, and anon members were connected), it was setting "%gActiveMembers" to false instead of "%gActiveMembersTypes". Idiot error, as usual.


In any case, thanks a lot for the help; I normally catch these kinds of stupid mistakes before considering asking for help, but regardless, it's working now.

Oh, and for the sake of searches, here's the $htmlfree alias I have.

Code:
alias -l htmlfree {
  ; It's local because it won't be used by the command line, only this file.
  ; Local aliases avoid conflicting names.
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}


Link Copied to Clipboard