|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
Starters I created a small snipplet for my dialog mainboard that retrives all topics/who started it/who posted last from the mirc forums scripts & popups section. I got 1 Error and 1 Question on Regex possibly. A) as quoted txt in my script i receive an error if someone on this board as an / in there subject it will not crlf the text it will add it to the next. Here is my script
alias irct { sockopen irct forums.mirc.com 80 }
on 1:sockopen:irct:{
.sockwrite -n irct GET /ubbthreads.php?ubb=postlist&Board=5 HTTP/1.1
.sockwrite -n irct HOST: forums.mirc.com
.sockwrite -n irct $crlf
}
on 1:sockread:irct:{
if ($sockerr > 0) return
var %x | sockread %x
if ($sockbr == 0) return
if (%x == $null) { return 2 }
if ($regex(%x,/(amp|[u,U]ser)/g) == 2) {
if ($regex(%x,/(amp|[u,U]user|Post)/g) == 3) { %irct = 8,1 $+ $+([,$remove($gettok($replace(%x,<,$chr(32),>,$chr(32)),4-,32),/a),]) $+ }
; Current issue arises when / is present in Token like in brannon's post it will not (crlf) the txt
if ($regex(%x,/(class|small)/g) == 2) { %irct = %irct 15,1was created 8,1 $+ $gettok($replace(%x,<,$chr(32),>,$chr(32)),3,32) $gettok($replace(%x,<,$chr(32),>,$chr(32)),7,32) $+ }
if (small !isin %x) && (nofollow isin %x) { %irct = %irct 15,1 $+ and 8,1 $+ $gettok($replace(%x,<,$chr(32),>,$chr(32)),4,32) 15,1 $+ was the last person to post. | echo -a %irct }
}
}
Here's my last output of script
[alphabetical sorting using iswm ] was created by Frenatic and deegee was the last person to post.
[floating text ] was created by WideOpenSpace and Lpfix5 was the last person to post.
[Easy question ] was created by Thrull and Thrull was the last person to post.
[Bar bot problems. ] was created by Dionysus and Dionysus was the last person to post.
[info from webpage ] was created by spermis and Lpfix5 was the last person to post.
[Server Dialog - How to remove it? ] was created by Sugna and Sugna was the last person to post.
[8 bit parsing rong ( i think it´s a bug ) ] was created by Miguel_A and Collective was the last person to post.
[$read ] was created by Mpot and Mpot was the last person to post.
[Need some help ] was created by BanJirian and deegee was the last person to post.
[RegSubex Question for the Pros ] was created by Buggs2008 and Buggs2008 was the last person to post.
[Script not working ] was created by foshizzle and deegee was the last person to post.
[Script not working ] was created by foshizzle and deegee was the last person to post. was created by brannon and brannon was the last person to post.
[echo text command ] was created by m0jad0 and kwell was the last person to post.
[rename file ] was created by sparta and sparta was the last person to post.
[Seeking a (simple?) scrambled word script. ] was created by Elixir and jaytea was the last person to post.
[rank script ] was created by spermis and Riamus2 was the last person to post.
[the winner is ] was created by spermis and spermis was the last person to post.
[always maximized windows ] was created by nataliad and nataliad was the last person to post.
[Retrieve processor model, speed and RAM ] was created by swgiant and Bekar was the last person to post.
[Setting a script to message a specific person ] was created by Nemmet and Nemmet was the last person to post. There you see a post by brannon that does not go on second line B) Instead of splitting text with $remove and using $replace to add spaces, is there a method of using regex or any other command to retrieve the specific info requested from the string? ex:. span class="small">by <a href="/ubbthreads.php?ubb=showprofile&User=79288" rel="nofollow">WideOpenSpace</a></span> WideOpenSpace would be the token I need. However its not static it changes of course... Is there a possible way to use regex to give me the data between rel="nofollow"> and </a> etc... for any other events I have in my script thanks.
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
A. The problem isn't the "/" character, your regex seeks " amp" which is also in " timest[color:red]amp[/color]". B. $nohtml (incuded below) C. Although you didn't ask  , you don't need to silence /sockwrite
alias irct { sockopen irct forums.mirc.com 80 }
on *:sockopen:irct:{
if ($sockerr) { return }
sockwrite -n irct GET /ubbthreads.php?ubb=postlist&Board=5 HTTP/1.0
sockwrite irct HOST: forums.mirc.com $+ $str($crlf,2)
}
on *:sockread:irct:{
if ($sockerr) { return }
var %x | sockread %x
if ($regex(%x,/&|#Post/)) {
if ( <a href* iswm %x) { %irct = 8,1$ +([,$nohtml(%x),]) }
if (<span class="small">* iswm %x) { %irct = %irct 15,1was created8,1 $nohtml(%x) }
if (<a href=*User*nofollow* iswm %x) {
%irct = %irct 15,1and 8,1 $+ $nohtml(%x) 15,1was the last person to post.
echo -a %irct
unset %irct
}
}
}
alias -l nohtml return $remove($regsubex($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,),$chr(9))
Edit: fixed parenthesis mismatch 
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
* /if: invalid format (line 12, script6.mrc) I used the nohtml code and fixed the regex lookup thanks
alias irct { sockopen irct forums.mirc.com 80 }
on 1:sockopen:irct:{
.sockwrite -n irct GET /ubbthreads.php?ubb=postlist&Board=5 HTTP/1.1
.sockwrite -n irct HOST: forums.mirc.com
.sockwrite -n irct $crlf
}
on 1:sockread:irct:{
if ($sockerr > 0) return
var %x | sockread %x
if ($sockbr == 0) return
if (%x == $null) { return 2 }
if ($regex(%x,/(&|[u,U]ser)/g) == 2) {
if ($regex(%x,/(&|[u,U]user|Post)/g) == 3) { %irct = 8,1 $+ $+([,$nhtml(%x),]) $+ }
if ($regex(%x,/(class|small)/g) == 2) { %irct = %irct 15,1was created 8,1 $+ $nhtml(%x) $+ }
if (small !isin %x) && (nofollow isin %x) { %irct = %irct 15,1 $+ and 8,1 $+ $nhtml(%x) 15,1 $+ was the last person to post. | echo -a %irct }
}
}
alias -l nhtml { return $remove($regsubex($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,),$chr(9)) }
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
oh lol, didn't know you were gonna reply so quick thanks.
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
$regex(%x,/(&|[u,U]ser)/g) [u,U] should be [uU], or use the /i switch (case insensitive) ("[u,U]ser" matches "user", "<comma>ser" or "User")However, if someone uses "User" or "user" or "small" or "class", or ",ser" as the RE is now, in the thread title, your count will again be wrong 
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
sorry I wish there was a better explanation of regex I only get stuff from knowledge and from sites but alot is php regex or c# regex that i get which is a tad different from mIRC
*$ is not even used apparently in mirc because when I tried a simple state like this ^(what|that|mat)*$ if i used *$ it didnt work while without *$ it searched the beginning for.. ()
also for alias -l nhtml { return $remove($regsubex($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,),$chr(9)) }
would I be correct in saying that $regsubex returns data that it find in (here|here) the use of $remove is of course to remove that data.
But how I learnt regex is that if ^ isin the beginning and after the ( like so (^ it becomes isnot so example (^[^<]*> would isnot [ isnot < matches *
LOL ok well as you can see I got myself confused could someone break that down for me please. I learn everything fast but regex wasnt used enough for me to knwo
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
Joined: Jun 2006
Posts: 508
Fjord artisan
|
Fjord artisan
Joined: Jun 2006
Posts: 508 |
sorry I wish there was a better explanation of regex I only get stuff from knowledge and from sites but alot is php regex or c# regex that i get which is a tad different from mIRC mIRC uses PCRE, there is the PCRE man page*$ is not even used apparently in mirc because when I tried a simple state like this ^(what|that|mat)*$ if i used *$ it didnt work while without *$ it searched the beginning for.. () $ matches the end of the line. The asterisk means 0 or more (of whatever pattern precedes it), it's not a general wildcard char like in iswm. //echo -a $regex(whats up,/^(what|that|mat).*$/) would match, but ".*$" is kind of pointless. //echo -a $regex(up to you,/you$/) matches as "you" is the end of the string, //echo -a $regex(up to you.,/you$/) won't match. would I be correct in saying that $regsubex returns data that it find in (here|here) the use of $remove is of course to remove that data. No, the $remove() is to remove $chr(9) (I could have added a \t into the RE to do it). That $resubex() has an empty substitute field, it returns whatever is left AFTER the matches are substituted with <nothing>. But how I learnt regex is that if ^ isin the beginning and after the ( like so (^ it becomes isnot so example (^[^<]*> would isnot [ isnot < matches * '^' negates a character class IF it's the first char in the class. following a parenthesis like that^ is the usual "at the beginning of the string" [aei] matches an "a" an "e" or an "i". [^aei] matches anything that is NOT an "a" an "e" or an "i".
|
|
|
|
Joined: Aug 2005
Posts: 1,052
Hoopy frood
|
OP
Hoopy frood
Joined: Aug 2005
Posts: 1,052 |
Awww thanks for the explanation I get it and those links help
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
|
|
|
|
|