FORUMS: list search recent posts

Expression to select and affect specific characters in a text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Enrique Rovira
Expression to select and affect specific characters in a text
on Jun 2, 2015 at 10:23:41 am

Ok so I have been trying to find this all over the internet but no luck so far.

I am trying to create an expression in a text layer so that a specific character is found in the text, like this bullet point: • (alt+8), a different colour is applied.

Any ideas?

Thx, E


Return to posts index

Dan Ebberts
Re: Expression to select and affect specific characters in a text
on Jun 2, 2015 at 4:46:22 pm

Try this.

Add a Fill Color Animator and set the color for the special character.

Add an Expression Selector.

Delete the Range Selector.

Replace the Amount expression in the Expression Selector with this:

myChar = "•";
if (text.sourceText[textIndex-1] == myChar) 100 else 0


Dan



Return to posts index

Enrique Rovira
Re: Expression to select and affect specific characters in a text
on Jun 2, 2015 at 5:51:15 pm

Thanks Dan, worked beautifully!


Return to posts index


Enrique Rovira
Re: Expression to select and affect specific characters in a text
on Jun 3, 2015 at 8:28:09 am

Actually I came across a problem, for some reason it selects the correct character on the first line but then selects and modifies the colour of the second character on the second line, the third character on the third line, and so on. Of course the bullet point is always the first character on each line.


Return to posts index

Enrique Rovira
Re: Expression to select and affect specific characters in a text
on Jun 3, 2015 at 8:53:07 am

We tried moving things around as below, but to no use!

myChar = text.sourceText.value[textIndex-1];
if (myChar === "•") { 100 } else { 0 };


Return to posts index

Enrique Rovira
Re: Expression to select and affect specific characters in a text
on Jun 3, 2015 at 9:07:04 am

We also tried this expression, from another of your posts actually.

But we get to the exact same problem, on each line will select a further character... If I put everything in one single line it works fine though.

c = text.sourceText.value[textIndex-1];
if (/^\•/i.test(c)) 100 else 0


Return to posts index



Dan Ebberts
Re: Expression to select and affect specific characters in a text
on Jun 3, 2015 at 4:02:42 pm

Try it this way:


txt = text.sourceText.replace(/\r?\n|\r/g,'');
myChar = "•";
if (txt[textIndex-1] == myChar) 100 else 0



Dan



Return to posts index

Enrique Rovira
Re: Expression to select and affect specific characters in a text
on Jun 3, 2015 at 4:23:27 pm

Ok now THAT worked perfect! I'm tinkering with it now but it seems all is fine.

Thanks!


Return to posts index

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