regex - Split a word with regexp in matlab; startIndex for 'split'? -


my aim generate phonetic transcription word according set of rules.

first, want split words syllables. example, want algorithm find 'ch' in word , separate shown below:

input: 'aachbutcher' output: 'a' 'a' 'ch' 'b' 'u' 't' 'ch' 'e' 'r' 

i have come far:

check=regexp('aachbutcher','ch');  if (isempty(check{1,1})==0)          % returns 0, when 'ch' found.     [match split startindex endindex] = regexp('aachbutcher','ch','match','split')     %now split 'aa', 'but' , 'er' single characters:    = 1:length(split)        singleletters{i} = regexp(split{1,i},'.','match');    end  end 

my problem is: how put cells together, such formatted desired output? have starting indexes match parts ('ch') not split parts ('aa', 'but','er').

any ideas?

you don't need work indices or length. simple logic: process first element match, first split, second match etc....

[match,split,startindex,endindex] = regexp('aachbutcher','ch','match','split');  %now split 'aa', 'but' , 'er' single characters: singleletters=regexp(split{1,1},'.','match');  = 2:length(split)    singleletters=[singleletters,match{i-1},regexp(split{1,i},'.','match')]; end 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -