ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Replace $ in text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Yan Trudel
Replace $ in text
on Jul 7, 2017 at 4:23:59 pm

I'm looking to replace special characters in text.
I'm using the replace function but for some reason it doesn't seem to work with $ signs.

Instead, it detects the $ and adds an S at the end of the text line.

Is there a trick to make it work or maybe i'm doing this wrong?

myText = comp("Control_HUB").layer("TITRE").text.sourceText;
myText.replace(/q|ç|ä|à|é|è|ê|ë|ô|ö|ü|ù/g,"e").replace(/,|;|ï|î/g,"i").replace(/$/g,"s");


Return to posts index

Dan Ebberts
Re: Replace $ in text
on Jul 7, 2017 at 4:35:56 pm

I think you have to escape the $ in a regexp with a backslash. Try it this way:

.replace(/\$/g,"s");


Dan



Return to posts index

Yan Trudel
Re: Replace $ in text
on Jul 7, 2017 at 4:53:10 pm

Once again, you save the day!

Thanks Dan, it works perfectly now! :)


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]