-
I want an expression to find a character’s No.of & Place of Occurance?
Okay the title won’t explains a lot. Let me explain it here….
I’ve a text layer having text as “HELLO” in it. And I applied the following expression to animate the text in it by a slider value.
txt = text.sourceText;
typeSlider = effect("Slider Control")("Slider");
letter = Math.round(typeSlider);
txt.substr(0,letter);So each time I increase the slider value each letter getting revealed one by one.
This is what I want to do. I want to check every new letter that revealing, If it’s a specific letter I want to know how many times it occured. For reference I’ve created an empty text layer and applied the following code to the sourceText property
slider = Math.round(thisComp.layer("HELLO").effect("Slider Control")("Slider"));
lastLetter = slider-1;
string = thisComp.layer("HELLO").text.sourceText
currentLetter = string.charAt(lastLetter);
if (currentLetter == "L"){
"The Letter is L"
}else{
currentLetter;
}So according to the code in the second text layer. It only reveals the last letter of first text layer. If the slider value is 2 the first Text layer only shows “HE” and the second Text layer shows “E”.
when the slider value turns 3 the first Text layer shows “HEL” and the second Text layer shows “The Letter is L” because the last letter is L so it check the if condition and reveal the string inside if condition.
But I want to know how many times the letter “L” is in the part of the first Text layer. I want to have a variable that increases itself by the number of occurance of letter “L”. So the variable must be 0 at first and when it sees the “L” at first time it should increased to 1. and when the slider values goes 4 (“HELL”) the variable should increaed to 2. and it should remember the slider value with it. Any idea???
==================================================================================================
Thanks in Advance…– Adirai Maji