Page 1 of 1

[0.6.14] Regex not working?

Posted: December 28th, 2011, 5:53 pm
by jocke
(Please feel free to move this to the beta-forums, as described here; I could not create any new topics there, so...)

Anyways.

Regexes in the RSS-section doesn't seem to work properly.

Given the following filters;

Code: Select all

0: Accept: .*[sS]([0-9]{2})[eE]([0-9]{2}).*
1: Accept: .*(720|1080)[pP].*
2: Accept: *
0 is assigned to category "tv", 1 is assigned to category "movies", while 2 goes to a default group.

All of the following entries is matched against filter 2;

Code: Select all

Beethoven.1992.720p.HDTV.x264-HD
The.Rocketeer.1991.720p.BluRay.x264-SiNNERS
Austin.Powers.The.Spy.Who.Shagged.Me.1999.1080p.BluRay.x264.iNT-WPi
Austin.Powers.International.Man.Of.Mystery.1997.1080p.BluRay.x264-iKA
However, they should be matched against filter 1.

Code: Select all

jocke@omg:~$ echo "Beethoven.1992.720p.HDTV.x264-HD" | grep -E ".*(720|1080)[pP].*"
Beethoven.1992.720p.HDTV.x264-HD
jocke@omg:~$ echo "The.Rocketeer.1991.720p.BluRay.x264-SiNNERS" | grep -E ".*(720|1080)[pP].*"
The.Rocketeer.1991.720p.BluRay.x264-SiNNERS

(and so on...)
Using "re:" in front of the filters, as described at the wiki doesn't help.

These filters used to work a while ago (I'm not entirely sure when they started to fail).

Am I missing something obvious?

Code: Select all

Version: 0.6.14 (from Git source)
OS: FreeBSD 9
Install-type: Source, via Git
Skin (if applicable): smpl Version: 1.3
Firewall Software: None
Are you using IPV6? It's enabled in the OS, but not in use by SABnzbd
Is the issue reproducible? Yes

Re: [0.6.14] Regex not working?

Posted: December 28th, 2011, 6:01 pm
by jocke
Hm, doing the following seems to work;

Code: Select all

Change
.*(720|1080)[pP].*

into
re: *(720|1080)[pP]*

The following fails;
re: .*(720|1080)[pP].*
However, ".*" should be valid Python regex, so I'm not entirely sure why it behaves like this...

Re: [0.6.14] Regex not working?

Posted: December 29th, 2011, 2:37 am
by shypike
That's not the way regexes work.
When you use ".*bla" the "bla" part will not be explicitly matched, because ".*" eats all.
In fact the ".*" is not needed at all because a regex tries to find a pattern within a larger string.
You don't need to specify the parts that you're not interested in.
So this is the correct regex:

Code: Select all

re: (720|1080)[pP]

Re: [0.6.14] Regex not working?

Posted: December 29th, 2011, 2:03 pm
by jocke
shypike wrote:That's not the way regexes work.
When you use ".*bla" the "bla" part will not be explicitly matched, because ".*" eats all.
In fact the ".*" is not needed at all because a regex tries to find a pattern within a larger string.
You don't need to specify the parts that you're not interested in.
So this is the correct regex:

Code: Select all

re: (720|1080)[pP]
I find it strange that both Bash and Perl disagrees with you. I mean, sure, in this case, you don't need the ".*"-part, but it should still work even if you use them.

Code: Select all

jocke@omg:~$ perl -e'$movie="Austin.Powers.The.Spy.Who.Shagged.Me.1999.1080p.BluRay.x264.iNT-WPi";print "$movie\n" if ($movie =~ /.*(720|1080)[pP].*/);'
Austin.Powers.The.Spy.Who.Shagged.Me.1999.1080p.BluRay.x264.iNT-WPi

jocke@omg:~$ echo "Austin.Powers.The.Spy.Who.Shagged.Me.1999.1080p.BluRay.x264.iNT-WPi" | grep -E ".*(720|1080)[pP].*"
Austin.Powers.The.Spy.Who.Shagged.Me.1999.1080p.BluRay.x264.iNT-WPi

Re: [0.6.14] Regex not working?

Posted: December 29th, 2011, 2:37 pm
by jocke
Even Python behaves as expected (both re.search and re.match);

Code: Select all

jocke@omg:~$ python -c "import re;movie=re.search('.*(720|1080)[pP].*','Austin.Powers.The.Spy.Who.Shagged.Me.1999.1080p.BluRay.x264.iNT-WPi');print movie.group(0);"
Austin.Powers.The.Spy.Who.Shagged.Me.1999.1080p.BluRay.x264.iNT-WPi

jocke@omg:~$ python -c "import re;movie=re.match('.*(720|1080)[pP].*','Austin.Powers.The.Spy.Who.Shagged.Me.1999.1080p.BluRay.x264.iNT-WPi');print movie.group(0);"
Austin.Powers.The.Spy.Who.Shagged.Me.1999.1080p.BluRay.x264.iNT-WPi

Re: [0.6.14] Regex not working?

Posted: December 31st, 2011, 7:09 am
by shypike
You should remove the space between re: and the actual expression.
The space won't ever match.
So:
re:.*(720|1080)[pP].*

I'll strip this space in the next release, because it should never be used anyway, but \s instead.

Re: [0.6.14] Regex not working?

Posted: January 1st, 2012, 6:22 pm
by jocke
shypike wrote:You should remove the space between re: and the actual expression.
The space won't ever match.
So:
re:.*(720|1080)[pP].*

I'll strip this space in the next release, because it should never be used anyway, but \s instead.
Ahhh. This explains a lot (-:

Thanks.