mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2012
Posts: 1
T
tefen Offline OP
Mostly harmless
OP Offline
Mostly harmless
T
Joined: Jan 2012
Posts: 1
Hey guys,

First time on the forums but spent a lot of time on #MSL on the IRC network. Great channel!

Here's the HTML as its seen from the page. (Please note the spaces prefixing the actual text on Line 4 before '>English').

Code:
<h4 class="inline">Language:</h4>

<a    onclick="(new Image()).src='/rg/tt-details/language-1/images/b.gif?link=%2Flanguage%2Fen';"     href="/language/en"   itemprop="inLanguage"
    >English</a>
</div>


Here's the mIRC code I have.. that's not matching.. frown

Code:
if ($bfind(&g,1,<h4 class="inline">Language:).text > 0) {
  if ($regex(language,$bvar(&g,1,$bvar(&g,0)).text,/<a\s\s?\s?\s?onclick="\(new Image\(\)\).src='/.+?/.+?/language.?.?/images?/..gif\x3Flink=.+?'\x3B"\s\s?\s?\s?\s?href="/language/.+?"\s\s?\s?itemprop="inLanguage".+\s*(\r\n)>(.*?)</a>/ig) > 0) {
    var %numberoflanguages = $regml(language,0)
    var %languagenumber = 1
    while (%numberoflanguages >= %languagenumber) {
      set %_imdb.movielanguage $iif(%_imdb.movielanguage == $null,$imdbcode($regml(language,%languagenumber)),%_imdb.movielanguage $+ $chr(124) $+ $imdbcode($regml(language,%languagenumber)))
      inc %languagenumber
    }
  }
}


Instead of the (\r\n) .... I've tried [\r\n]* .. no dice either.

Hopefully I'm able to get some help here.


Thank you very much

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Did you try to debug the code?
Are you sure the binvar contains what you are expecting it to contain?
You are not escaping your slash and since it's what you use to delimit the pattern, the first non escaped slash is probably used as the end of the pattern with the rest being switches.
I also think you have a problem around your \r\n, after the quote, there is nothing to match before the newline, but you used the + quantifier with the dot which requires at least one match, in general you should try to reduce the pattern and see if it matches, then extend the pattern to fit your needs etc etc.

Note: You are not escaping some dot in your pattern, it's not a problem since a dot match any character including a litteral dot but still, I thought I would mention that.
You also don't need to use the hexa form of a ';'

Last edited by Wims; 11/01/12 03:54 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Your regex is matching "\r\n>", which is not what you're showing in your paste. The paste has whitespace after the newline. You also have ".+" after the last attribute when there is no extra data prior to the newline in your pasted example.

I don't think this is a problem with the binvar stuff, I think it's a problem with your regex. Test that your regex matches the input if you pass it in manually (manually set a bvar with /bset or /bread from a file with sample data and verify).

As a sidenote, the server might return only \n in a newline, so your regex should have \r?\n, not \r\n.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
  if ($bfind(&test,1,<h4 class="inline">Language:).text) { 
    if ($regex($bvar(&test,1-).text,/<a [^>]+>(.+?)</a>/)) { echo -a $regml(1) } 
  }


Link Copied to Clipboard