-
Split() expression with If else
hello guys,
I have a text layer with below given expression on sourceText property which tries to grab names from the comp which has list of 208 countries name in it. Every country is a precomp and has a respective code and county name on it eg. IND – INDIA.
id = thisComp.layer("CONTROL").effect("SELECT COUNTRY")("Menu");
c = comp("Country Names").layer(id).name.split("-")[1];but my problem starts where the country name like USA are written which only has code in name due to character limitation in design. So I am trying to write an if/else statement which can check based on “-” in name. So names without “-” will be used as written on precomp. I came up with below expression but this won’t work as expected.
id = thisComp.layer("CONTROL").effect("SELECT COUNTRY")("Menu");
c = comp("Country Names").layer(id).name;
if(c.split("-")>0){c.split("-")[1]} else {c};Thank you!