Galileo looking through a telescope

Find-n-replace for expressions

This is a tool for finding and replacing text in expressions. It uses javascript regular expressions to do the job, so you can do complex search and replaces, but regular ol’ find foo replace with bar will still work, as long as you escape any special characters like ()[].*^ and \. To escape a character you put a backslash in front of it. So to search for the literal string [foo] you’d search for \[foo\] (square brackets in regular expressions denote a range of characters, so if you wanted to search for any one of the letters b, a, or r you’d use [bar]).

Teaching regular expressions is waaaay beyond the scope of this little blog, there are a ton of resources out there written by people who actually study this kind of thing. A starter is the mozilla documentation.

Search Patterns

The regular expressions, or plain text that you want to search for, and then replace with, e.g. foo and bar or f([o]*) and b$1r

Global

Don’t give up after finding the first match. e.g. in the text foobarfoo the search pattern foo will match twice with global on, and once without.

Case-Insensitive

Search without considering case. E.g. foo will match Foo and FOO

Multi Line

Search patterns can include line breaks.

‘.’ matches newline

The character . normally matches any character, except for newlines (line breaks). Turn this on and it will match them.

Installing After Effects Scripts

Recent versions of After Effects will take care of the installation for you. For scripts with a UI, go to the File menu in AE and choose Scripts>Install Script UI Panel. Point it at the unzipped .jsx file that you just downloaded and let it work its magic, then restart AE.

Running the script

Once the script is installed it should appear in AE’s Window> menu. Calling the script from this menu will make its window appear, and it can then be docked like any other panel. If you want it to always be visible, add it to your workspace.

Download

You can download this script along with all my other scripts here. Or to download just this script click the download button below.

One comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.