SOLVED:Trying to set basic two word Regex with lookaround

I’m writing this after asking about this and then finding the answer myself… So in order to match regular expressions with look around, I finally got the following working. I think the biggest part was i didn’t have the beggining and trailing /

I also don’t have word boundary’s because apart from Mr. Andr0iD , I don’t expect it more likely these keywords to be side by side without a space than to appear randomly as part of a episode title…

I am now just gonna do all capturing with the following tags. I’ve set all qualities as acceptable (hdtv, web-dl etc)

/^(?=.*10bit)(?=.*1080p).*$/i
Match 10bit and 1080p - This is my most preferred format and eventually I want to archive 1080p HEVC 10bit rips. I didn’t add hevc in the expression because I’ve only seen 10bit in conjunction with HEVC to begin with.

/^((?=.*265)|(?=.*hevc))(?!.*1080p).*$/i
MATCH 265 OR hevc AND NOT 1080p - This rule will match anything this isn’t 1080p and is still hevc. IE 720p and under.
Please note that ?! denotes DO NOT MATCH and ?= means MATCH

/^(?!.*xvid)(?!.*1080p)(?!.*720p).*$/i
Finally, This rule says that it will not accept xvid releases in 720p or 1080p. ( I Don’t have 4k qualities enabled). IE, it filters out all the xvid releases in the SD standard definition range.

So, Ultimately these three rules, once you set all profiles enabled and order by resolution will start with ANY NON XVID release in standard definition.

It will upgrade to 720p if it finds one in HEVC or 265

Then it will upgrade to 1080p if it finds one in 10bit.

I’ve left the original post where I asked how to do this out of Humility.


Hello, I’m trying to write a regular expression to match “10bit” & “1080p”

I’ve tried (?=.*t)(?=.*1080p).* and it works at regex101 but not in sonarr.

I want to set it along with NOT 1080p AND (hevc OR 265) which in regex was (?!.*1080p)(?=.*hevc).*

so that it will grab whatever hevc release comes along in proceeding quality upto 720p but it will only match 1080p releases in 10bit.

I’ve always wanted a way to apply tags to profiles but if i can set those two “tags” above then I can set a whole bunch of others and just use the ANYQUALITY profile.

Thanks

edit… had a thought to just set two expressions, 1080p.*10bit and 10bit.*1080p but those don’t match either, do i have to enable regex somewhere in the settings?

1 Like

Doing lookarounds like that is really unwise. Lookarounds should be minimized as much as possible.
The .* wildcards should also be avoided unless it’s needed.

If you’re not familiar with regex, then please stick with the simple ones like /\b[hx]265\b/i.

The regex function was never intended to do complex expressions, but only to simplify like the one above.

Are those expressions i’m using actually that complex? I could just do 6 of them instead without the lookarounds, ie 10bit.*1080p AND 1080p.*10bit

Is it a security issue? Cause I don’t really care if my RPi has to work a little bit harder :stuck_out_tongue:

The target strings aren’t that long, so the performance hit isn’t going to be big. But yes, those expressions are time complex. Littered with greedy quantifies and lookarounds.

But forget I said anything, it’s not my problem.

it’s all good :blush: I was quite proud of myself when I worked it out though. If it’s just performance hit then I don’t care if it means I can set a ton of specific profiles. Ultimately, I think it would be great if you could use expressions like those as the quality settings.

IE, you could rank AMZN 10bit 1080p WEB-DL as being its own quality setting akin to HDTV-720p and then set that to a higher quality than 10bit 1080p WEB-DL by itself. Or rank 1080p TBS as it’s own quality that is acceptable but ranked lower that SD.
.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.