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 -

amazon web services - When using Cognito credentials with AWS in a browser (javascript), keep getting "missing credentials" error -

c# - How to set the datatextfield value instead of the value on a drop down list? -