MATLAB: Matlab – verify if a string have any number string hi everyone; I have a string and i need to verify if there are any number. for example str='scramble3' and i need a answer like, True or 1(to yes) and False or 0(to no) Thanks Best Answer you can use the function regexp.example:~isempty(regexp('scramble3','\d'))would return a 1.if you leave out the isempty check then it'll return 9 which is the index position of the number. Related SolutionsMATLAB: How to check if string contains some special character For #1 you could use isstrprop().For #2, see startsWith(str, '_') and endsWith(str, '_')For #3, you can use find():indexes = strfind(str, '__');For #4 you could do something likeif str(1) >= '0' && str(1) <= '9' % str starts with a numerical digit.else % str does not start with a numerical digit.end MATLAB: How to read only vowels of a string >> regexprep('How to read only vowels of a string?', '[^aeiouAEIOU]', '')ans = 'ooeaooeoai'>> char(regexp('How to read only vowels of a string', '[aeiouAEIOU]', 'match'))'ans = 'ooeaooeoai'(edit) No longer ignoring capitals! Related QuestionRemove parenthesis and the contents inside from a stringRegexprep() skip first occurrenceHow to locate a string in Matlab, getting the index of the stringExclude Digits from String using Regexp in MATLABDetecting the existence of alphabetical elements
Best Answer