ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Parse and remove any numbers from a text layer (Source Text)

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ter Ber
Parse and remove any numbers from a text layer (Source Text)
on Nov 16, 2017 at 1:13:17 pm
Last Edited By Ter Ber on Nov 16, 2017 at 2:18:54 pm

Hi,

I have a text layer that gets the .sourceText from another layer's markers. The problem is that these markers contain numbers that I want to remove from the string.

So the expression I now use on the Source Text is orignially Dan Ebberts.

This gives me a source text string like "11 hello world" and I want it to display just "hello world".

Anybody know how to modify Dan's excellent script to accomplish this?

m = thisComp.layer("Ketil");
n=0;
if (m.marker.numKeys > 0){
n = m.marker.nearestKey(time).index;
if (m.marker.key(n).time > time) n--;
}
if (n > 0) m.marker.key(n).comment else ""




Return to posts index

Dan Ebberts
Re: Parse and remove any numbers from a text layer (Source Text)
on Nov 16, 2017 at 4:00:24 pm

This might work if the numbers are always there and always at the beginning of the comment. Otherwise, it gets more complicated.


m = thisComp.layer("Ketil").marker;
n=0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time) n--;
}
if (n > 0){
s = m.key(n).comment;
if (s.indexOf(" ") > -1)
s.substr(s.indexOf(" ") + 1)
else
s;
}else ""



Dan



Return to posts index

Ter Ber
Re: Parse and remove any numbers from a text layer (Source Text)
on Nov 20, 2017 at 10:37:04 am

Thanks Dan!

Your approach makes sense, but I actually found a different answer that worked before you replied. I tried to update my post as "answered", but was censored by the moderator?!😲
Hopes this reply goes through.

PS pretty proud of myself figuring out this by myself before Dan himself came to the rescue. My solution worked, but Dan's solution is probably more well-considered?

Thanks anyway 😄

m = thisComp.layer("Ketil");
n=0;
if (m.marker.numKeys > 0){
n = m.marker.nearestKey(time).index;
if (m.marker.key(n).time > time) n--;
}
if (n > 0) m.marker.key(n).comment.replace(/[0-9]/g,'') else "not available"




Return to posts index

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