Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions find and replace – to + and vice versa

  • find and replace – to + and vice versa

    Posted by Dennis Cheung on October 31, 2019 at 6:26 pm

    Hello

    I’ve gone through the forum looking for a way to find and replace the “+” or “-” symbol in the text layer above and switch to its opposite value. For example: if layer 1 shows “+7,” layer 2 should be “-7,” or layer 1 shows “-10,” layer 2 should be “+10.”

    this code I have isn’t working:
    thisComp.layer(index-1).text.sourceText.replace(/\u002B/gi,"-").replace(/\u002D/gi, "+");

    Thanks for your time everyone and thanks in advance for any and all solutions

    Dan Ebberts replied 6 years, 6 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    October 31, 2019 at 7:26 pm

    Will it be one or the other (or neither)? If so, this should work:


    txt = thisComp.layer(index-1).text.sourceText;
    if (txt.indexOf("-") > -1)
    txt.replace(/\u002D/gi, "+")
    else
    txt.replace(/\u002B/gi,"-");

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy