MATLAB: Splitting the string using regular expression or string split stringsplit 'a_bb_ccc_ddd_eeeeee_ffff_gg_h_i' I have a string like this. I need to split the string as a_bb_ccc ddd_eeeeeee ffff_gg_h_i how to use the regular expression or stringsplit in order to get the above output? Best Answer s = 'a_bb_ccc_ddd_eeeeee_ffff_gg_h_i'index = strfind(s, '_');parts = {s(1:index(3)-1), s(index(3)+1:index(5)-1), s(index(5)+1:end)} Related SolutionsMATLAB: Concatenating string in a unique string horzcat(A{:})orstrjoin(A, '') MATLAB: How to use regular expression to match the last character of a sentence Here's a regular expression that might be helpful, which matches if the last character in the string is "." or "!" or "?". >> candidate = 'Is this a sentence?'; >> regexp(candidate, '.*(\.|!|?)$') Related QuestionString parsingReplacing a string with another and vice versaString help!How to use regexp to break a string based on the first set of parenthesesString compareRegular Expression to match strings after a certain number of words that do not contain a keywordDisplay+string
Best Answer