Method Reference: string.endsWith

string: TF = endsWith (str, pattern)
string: TF = endsWith (str, pattern, 'IgnoreCase', true)

Test if strings end with pattern.

TF = endsWith (str, pattern) returns a logical array TF of the same size as A containing true for each corresponding element of str that ends with the specified pattern and false otherwise. Similarly to NaN values, <missing> elements do not match any pattern and always return false.

TF = endsWith (str, pattern, 'IgnoreCase', true) ignores case when determining if str ends with pattern.

Source Code: string

Example: 1

endsWith tests whether each string ends with a given suffix.

 files = string ({'cat.txt'; 'dog.csv'; 'fish.txt'})
files =
  3x1 string array

    "cat.txt"     
    "dog.csv"     
    "fish.txt"
 endsWith (files, '.csv')
ans =

  0
  1
  0