Using Regular Expressions in Predicates

Predicates using the matches condition allow you to make use of Regular Expressions in rules. Using Regular Expressions you are able to do the most advanced matching and parsing available. That way you are also able to extract specific part of a string to use later on in your rules.

A nice example of this is matching for TV Shows with a naming similar to

Show.S##E##.mkv

You can create a rule with the predicate

Original Filename matches ('my_show'.+)[sS]('my_season'[0-9]+)[eE]('my_episode'[0-9]+)

Now if a filename matches the shown Regular Expression the part identified as show, season and episode will be captured in the named captured groups denoted by ('name'). The syntax of these named captured groups deviates slightly from the ICU standard.

In the action part of the rule you can now add a custom tag to use the captures. For this example you just create an action saying

Set Show to {my_show}

The {my_show} is converted to a tag that automatically uses the capture group named my_show.

Note: Regular Expressions is a very advanced topic and this article is not intended to teach you about Regular Expressions, but to give you and ideas how you can use them in rules. If you run into any problems, please contact support directly.

Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk