Regular expression or Regex has been around since the 80`s and it can be found in most high level programming languages and so TCL is no exception. It's main application is to find/replace matches in strings. Generally, this is a module that many programmers feel really strongly about be it negative or positive for multiple reasons but mostly because this is a "language" that can be brutally abused like in this imfamous example that is about validating an email address.

If you need some help making up your mind about Regex here is a really fantastic assessment.

I am not going to debate whether you should use it or not, rather would like to focus on explaining some basics and show some useful things you can do with regex in Nuke as for most compositors this might seem like an alien language ( rightly so btw ). Also, because I haven't met but one example online in which tokeru used a bit of regex to extract the seriel number of the node it felt like a good opportunity to introduce it to fellow compositors.


Let's start with how a regex code should look like in Nuke!

[ regexp -inline {\d+} [value name]]

There are a few parts in here that we can break down:

1 [ ] - First of all, every TCL code in Nuke should be in square brackets. 

2 regexp - Starting a code with calling the module.

3 -inline - Regex supports multiple switches that should starts with " - " and determines the output.

4 {\d+} - This is where the interesting part happens which is called expression string. This part should be in curly brackets "{ }".

5 [value name] - The string we would like to make the regex run on or match variable.

Re types

regexp - Match a regular expression against a string

regsub - Perform substitutions based on regular expression pattern matching

Line Anchors

Hope you will find it useful!