mIRC Home    About    Download    Register    News    Help

Print Thread
How to detect a TV Show using $regex #262185 08/01/18 11:37 AM
Joined: Nov 2003
Posts: 82
C
colt45 Offline OP
Babel fish
OP Offline
Babel fish
C
Joined: Nov 2003
Posts: 82
Code looks right to me, but what I can't figure out why it's not working for me?

Code:
if ($regex([Ss]?)(\d{1,2})([xXeE\.\-])(\d{1,2}) isin $1-) {
  //echo -a TV Show Detected : $1-
}


Quote:
* Invalid parameters: $regex


I've been trying various ways to get it to work but no luck since last night - right now i'm having a bit of a headache! - lol
I possibly have a dementia - coding is like way past my time frown

Re: How to detect a TV Show using $regex [Re: colt45] #262187 08/01/18 05:10 PM
Joined: Jan 2004
Posts: 1,437
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,437
You have matching count of open/close parenthesis but they're mis-matched, so the $regex ends right after the question. Also, after you fix that, if $1- contains color codes which are not part of a wildcard string you may need to use $strip($1-)

Re: How to detect a TV Show using $regex [Re: maroon] #262192 08/01/18 07:55 PM
Joined: Nov 2003
Posts: 82
C
colt45 Offline OP
Babel fish
OP Offline
Babel fish
C
Joined: Nov 2003
Posts: 82
Can you give me an example of what it should be?
As my english is not good so I'm struggle to understand your answer frown

Re: How to detect a TV Show using $regex [Re: colt45] #262194 08/01/18 09:28 PM
Joined: Jan 2004
Posts: 1,437
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,437
I added parenthesis in a way which pairs them logically. Whether this is the correct regex depends on what your input string looks like. I got it to match like:

Code:
//tokenize 32 test12-34 | if ($regex($strip($1-),([Ss]?)(\d{1,2})([xXeE\.\-])(\d{1,2}))) echo -a $1- returns $v1 / $regml(1) / $regml(2) / $regml(3) / $regml(4)


Re: How to detect a TV Show using $regex [Re: maroon] #262199 08/01/18 10:06 PM
Joined: Nov 2003
Posts: 82
C
colt45 Offline OP
Babel fish
OP Offline
Babel fish
C
Joined: Nov 2003
Posts: 82
The line would shows anywhere in the line something like this
Quote:
Coronation.Street.S59E08.720p
or sometimes very rare, it shows
Quote:
Coronation.Street.59x08.720p

It could be in the 2nd word of the line .. or in the 7th word in the line - So this is why I want it to detect a SERIES/SOAP by reading the line with S**E** or **x** .. then keep a log of it by echo'in back into my @Windows.

I've tried your code, doesn't really do anything? Except it's flooding me with this
Quote:
test12-34 returns 1 / / 12 / - / 34


Thanks

Re: How to detect a TV Show using $regex [Re: colt45] #262200 08/01/18 10:34 PM
Joined: Jan 2004
Posts: 1,437
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,437
My code wasn't a replacement for your ON TEXT event, it created $1- to test the match. Regex returns 0 if no match, so the 1 indicates a match.

//tokenize 32 Coronation.Street.S59E08.720p | if ($regex($strip($1-),([Ss]?)(\d{1,2})([xXeE\.\-])(\d{1,2}))) echo -a $1- returns $v1 / $regml(1) / $regml(2) / $regml(3) / $regml(4)

shows: Coronation.Street.S59E08.720p returns 1 / S / 59 / E / 08

The '1' means regex found a match. The next 4 strings are the matches for the 4 groups inside parenthesis. ([Ss]?) matched the S and (\d{1,2}) matched the 59 etc. Those are just helpful in debugging why it matches things it should not. Your event would just have something like:

Code:
on *:TEXT:*:#channelname:{
  if ($regex($strip($1-),([Ss]?)(\d{1,2})([xXeE\.\-])(\d{1,2}))) aline @windowname Match Regex Found in $chan : $nick $1-
}

Re: How to detect a TV Show using $regex [Re: maroon] #262206 09/01/18 11:27 AM
Joined: Nov 2003
Posts: 82
C
colt45 Offline OP
Babel fish
OP Offline
Babel fish
C
Joined: Nov 2003
Posts: 82
Seems to work!! laugh
Many thanks - will keep the original code backed up .. now I need to tweak few things around and test further myself .. but your code does it for me nicely smile

Thanks

Re: How to detect a TV Show using $regex [Re: colt45] #262397 28/01/18 05:38 PM
Joined: Nov 2003
Posts: 82
C
colt45 Offline OP
Babel fish
OP Offline
Babel fish
C
Joined: Nov 2003
Posts: 82
I've another questions if you don't mind me asking...

Code:
if ($regex($strip($1-),([\.\-\_\$chr(32)])(German)/i)) {
     //echo @Non-English Non-English : $strip($1-)
}


Because from time to time, I noticed sometimes it has a space in it and it wouldn't detects it. - I'm guessing regex doesn't like $chr(32) ?

Also, sometimes german doesn't picks up cos sometimes it filtered as German (Cap Case) .. I've tried adding /i or \i in the end of the regex line but appears it's not doing anything for me.

Hope for answer smile

Thanks