Highlighted

[Expression on SourceText] I want an expression to find a character's No.of & Place of Occurance?

Participant ,
Mar 09, 2020

Copy link to clipboard

Copied

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???

TOPICS
Dynamic link, Expressions, How to

Views

342

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

[Expression on SourceText] I want an expression to find a character's No.of & Place of Occurance?

Participant ,
Mar 09, 2020

Copy link to clipboard

Copied

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???

TOPICS
Dynamic link, Expressions, How to

Views

343

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 09, 2020 0
Most Valuable Participant ,
Mar 10, 2020

Copy link to clipboard

Copied

It would help if you actually started to learn Javascript:

 

https://www.w3schools.com/jsref/jsref_indexof.asp

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 10, 2020 0
Guide ,
Mar 10, 2020

Copy link to clipboard

Copied

Just a rough idea:

Since you know the final word in the first place, you can count the appearance of the desired letter in one go.

You'll have to safe the index where the letter was counted and compare this to the current silder value. 

 

*Martin

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 10, 2020 0
Adobe Community Professional ,
Mar 10, 2020

Copy link to clipboard

Copied

You would use Regular Expressions - https://www.w3schools.com/jsref/jsref_obj_regexp.asp

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 10, 2020 0