I would like to get only the begining of string , is there an equivalent matlab that allows to say : startsWith('It-is') like in java?
Thanks
You can use the strfind
function to tell if one string starts with another. The function returns the starting index of each occurrence of the string you're looking for, or an empty array if the string is not found.
S = 'Find the starting indices of the pattern string';
strfind(S, 'It-is')
If the string started with 'It-is'
then the first index of the array returned by strfind
would be 1 (i.e. the index of the first character).