Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Extendscript: How to check string ends with

Participant ,
Nov 30, 2017 Nov 30, 2017

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

TOPICS
SDK
4.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Dec 01, 2017 Dec 01, 2017

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

Translate
Engaged ,
Dec 01, 2017 Dec 01, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 03, 2017 Dec 03, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 03, 2017 Dec 03, 2017
LATEST

Neat!

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