ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

&& is referencing only part 2

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott McGee
&& is referencing only part 2
on Jun 28, 2017 at 2:28:38 pm

I've reached the end of project and realised that I haven't taken into account. If my colleagues type in Weekdays/Weeknights 7.30pm & 8.30pm, the text goes over the edge of my border I've created.

a = text.sourceText;
if (a.indexOf ("Weekdays" && ".30pm &") != -1){
"Weekdays" +"\r"+ a.substr(9,25)
}
else if (a.indexOf ("Weeknights" && ".30pm &") != -1){
"Weeknights" +"\r"+ a.substr(12,25)
}
else
a;


but it seems to ignore the first word and only looks at ".30pm &", which I don't want it to. Any ideas?


Return to posts index

Scott McGee
Re: && is referencing only part 2
on Jun 28, 2017 at 2:35:04 pm

I'm an idiot once again.

For anyone having issue to find multiple words using indexOf

a = text.sourceText;
if (a.indexOf (("Weekdays") && (".30pm &")) != -1){
"Weekdays" +"\r"+ a.substr(9,25)
}
else if (a.indexOf (("Weeknights") && (".30pm &")) != -1){
"Weeknights" +"\r"+ a.substr(12,25)
}
else
a;


Return to posts index

Scott McGee
Re: && is referencing only part 2
on Jun 28, 2017 at 2:43:50 pm

Nope I was too quick to respond

a = text.sourceText;
if (a.indexOf (("Weekdays") && (".30pm &")) != -1){
"Weekdays" +"\r"+ a.substr(9,25)
}
else if (a.indexOf (("Weeknights") && (".30pm &")) != -1){
"Weeknights" +"\r"+ a.substr(12,25)
}
else
a;


if I type "Weeknights 7.30pm & 8.30pm", the result ends up

Weekdays
s 7.30pm & 8.30pm


Return to posts index


Scott McGee
Re: && is referencing only part 2
on Jun 28, 2017 at 3:27:06 pm

Not the way I wanted to write it, but this works

input = text.sourceText;
result = text.sourceText;
for (var i = 1; i <= 24; i++){
if (input.indexOf("Weekdays "+i+".30pm &") > -1){
result = input.substr(0,8) +"\r"+ input.substr(9,25);
break;
}
else if (input.indexOf("Weeknights "+i+".30pm &") > -1){
result = input.substr(0,10) +"\r"+ input.substr(11,25);
break;
}
}
result


Return to posts index

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