Activity › Forums › Adobe After Effects Expressions › Affect only Upper-case characters
-
Affect only Upper-case characters
Posted by Manske Massis on February 11, 2013 at 10:59 amHello,
I am working on project where users input a lot of text.
I need to display the text as follow:
All upper-case characters have a Stroke effect on them and all lower-case are just normal.Is there a way to affect only upper-case characters? Maybe with expressions?
Any help on this would be great!
ThanksManske Massis replied 13 years, 7 months ago 2 Members · 8 Replies -
8 Replies
-
Dan Ebberts
February 11, 2013 at 7:09 pmYou could create your text with stroke applied, add a Stroke Width Animator, set the Animator’s Stroke Width to the negative of the original text’s stroke width (e.g. if the original text has a stroke width of 3, set the animator’s stroke width to -3). Add an Expression Selector, delete the Range Selector, and apply this expression to the Expression Selector’s Amount property:
s = text.sourceText;
upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (upperCase.indexOf(s[textIndex-1]) > -1) 0 else 100
Dan
-
Manske Massis
February 12, 2013 at 9:35 amTnx for your reply.
It’s almost the solution.
The only thing is that it aplies a stroke on random characters, and not on the ones I specify in the expression. Any idea? -
Dan Ebberts
February 12, 2013 at 2:21 pmWhich characters? Did you alter the expression from what I posted?
Dan
-
Manske Massis
February 12, 2013 at 5:19 pmHmmm, I have nothing changed in your expression.
It looks like when I just type the text it works.
But when I paste in text, it applies strokes on random characters.
And then even when I type characters sometimes, for instance BBBbbb, Only the third B is with stroke.Could it maybe that the script is not compatible with line-breaks/Enters? Because after a Enter only the second Upper-case character gets applied with a stroke.
Tnx
-
Dan Ebberts
February 12, 2013 at 5:50 pmThat’s interesting. The Expression Selector’s “Based On” parameter has to be set to “Characters”, but even then textIndex seems to not include carriage returns. This should eliminate that problem:
s = text.sourceText.replace(/\r/gm,"");
upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (upperCase.indexOf(s[textIndex-1]) > -1) 0 else 100
Dan
-
Manske Massis
February 12, 2013 at 7:00 pm -
Dan Ebberts
February 12, 2013 at 7:24 pmLook at the first line of the expression. Between the two forward slashes should be just a backslash character followed by an “r”. The backslash in your expression got converted to the HTML equivalent. Making that change fixes it for me.
Dan
-
Manske Massis
February 12, 2013 at 7:32 pmYeah!
You are the man, Dan!I feel very stupid I overlooked it, sorry.
You saved me a lot of time. Thank you for giving me some of your time.
Reply to this Discussion! Login or Sign Up