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

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -