matlab - Compare last charaters of strings -


i need compare last characters of strings in matlab. natively following:

string = 'foobar'; len_string = length(string); if len_str_2 >= 3    str_suffix = str_2(len_str_2 - 2:len_str_2);    strcmp('bar', str_suffix) end 

is there simpler way this? strncmp can compare first n characters.

this sounds typical job regular expression:

any(regexp('foobar','bar$'))  %% return true any(regexp('foobars','bar$')) %% return false 

the dollar sign enforces pattern @ end of string.


Comments

Popular posts from this blog

javascript - IndexedDB error: Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned -

java - Unable to make sub reports with Jasper -

Integrity error when loading fixtures for Selenium testing in Django -