Copy link to clipboard
Copied
Hello All,
How to check a string ends with a particular string in extendscript? Where can I find the string api?
Premiere Pro Version: 12.0.0
Extension Type: Panel
Thanks & Regards,
Meet Tank
1 Correct answer
Hi Meet,
you mean like typing "String." in ExtendScript Toolkit CC, revealing the String methods?
You could use .substr with a negative offset (ex.: substr(-8,8) returning the last 8 characters of the string), or .match and use a regular expression like /[.]*edit/ , returning true if the string ends with "edit".
Best,
Erik
Copy link to clipboard
Copied
Hi Meet,
you mean like typing "String." in ExtendScript Toolkit CC, revealing the String methods?
You could use .substr with a negative offset (ex.: substr(-8,8) returning the last 8 characters of the string), or .match and use a regular expression like /[.]*edit/ , returning true if the string ends with "edit".
Best,
Erik
Copy link to clipboard
Copied
Hi Meet,
You can also add this function to your script :
String.prototype.endsWith = function( str ) {
return this.substring( this.length - str.length, this.length ) === str;
};
And then use it as a string method.
var a = "Hello Meet";
a.endsWith("Meet") --> will return true.
Cheers,
Peleg
Copy link to clipboard
Copied
Neat!