Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Blog Article - Introduction to Regular Expressions, Reproducible Code + lots of sample Expressions

Valorous Hero ,
May 04, 2025 May 04, 2025

Regular Expressions are exceptionally useful in After Effects Expressions. If you're thinking of improving your Expressions to write more intelligent code or even to craft Intelligent Design Assets (IDAs) to help speed up your development of Responsive and even Automated Motion Graphics MoGRTs and Motion Toolkits, then you MUST know the basics of Regular Expressions - there are two links to video tutorials to help you build a good foundation.

I've also added an example prompt you can use in a Large Language Model or with an AI Code Helper.

And you also get quite a few Regular Expressions that you can readily use. 

https://www.broadcastgems.com/post/here-s-an-excellent-after-effects-expression-you-should-have-in-y... 

Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
TOPICS
Expressions , How to , Resources
200
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 05, 2025 May 05, 2025

Thanks for another gem, @Roland Kahlenberg. Good one! Keep posting.


Thanks,
Nishu

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 05, 2025 May 05, 2025

Thanks for the kind words, Nishu. 

There's definitely lots more to come. I have enough content to last until the end of the year and they're scratching the surface stuff. I wish I could do these a lot more quickly and with fewer errors too - it takes a while to correct typos and there are still issues with synching my brain and my fingers - as I type on para 1, I'm thinking of paras 2-4.  😄


Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 10, 2025 May 10, 2025

Good day. I apologize if I am writing in the wrong thread, I am in despair, I can not solve the problem:

I need to Create a Control Text Layer (donor text), and bind another layer with text to it, so that any changes in (donor text) would affect all other bound layers with text.

The expression "thisComp.layer("donor text").text.sourceText" only changes the content of the text! But the style, font and other attributes are not transferred to the bound layers!!!

The option from the GPT chat does not work either:

srcDoc = thisComp.layer("donor text").text.sourceText;
dstDoc = createTextDocument(srcDoc.text); // clone with the same text
------------------------------------
// transfer the main styles
dstDoc.font = srcDoc.font;
dstDoc.fontSize = srcDoc.fontSize;
dstDoc.applyFill = srcDoc.applyFill;
dstDoc.fillColor = srcDoc.fillColor;
dstDoc.applyStroke = srcDoc.applyStroke;
dstDoc.strokeColor = srcDoc.strokeColor;
dstDoc.strokeWidth = srcDoc.strokeWidth;
dstDoc.leading = srcDoc.leading;
dstDoc.tracking = srcDoc.tracking;
dstDoc.justification = srcDoc.justification;

dstDoc; // must return an object
------------------------------------

What am I doing wrong? Where is the error?

the condition for setting up the project is met:
A. Setting up the project
File → Project Settings → Expressions
Expression Engine = JavaScript (important!)
Click OK, save the project, close AE and open it again.

B. Global setting Preferences
Edit → Preferences → Scripting & Expressions
▢ Enable Legacy Extendscript Expressions (must be unchecked!)
☑ Enable JavaScript based Expressions

---------------------------
Please help. Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 10, 2025 May 10, 2025
LATEST

The code you shared is part of ExtendScript and not for use as an Expression. When you prompt the LLM, you should let it know what you want - ExtendScript or Expression. 

On Text Style Expressions, Text Style and Source Text are two different Expression Methods. If you want both, you need to declare both, separately. 


So, something like this - 

// get the source text

const sourceText = thisComp.layer("donot text").text.sourceText;


// get style from the source text
const sourceTextStyle = sourceText.style;


// declare source text style and the source text
// text style declarations begin with a style declaration followed by text style attributes including the source text
setText() Expression Method.
sourceTextStyle.setText(sourceText)



// if you don't want the text from the source text but the text from the 'follower layer', you leave out the source text and declare just the style from the 'main/donor text'.

sourceTextStyle

HTH


Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines