Suppose I have a string \'johndoe@hotmail.com\'
. I want to store the string before and after \"@\" into 2 separate strings. What would be the easiest method of
If this thread isn't completely enumerated by now, may I add another? A handy perl-based MATLAB function:
email = 'johndoe@hotmail.com';
parts = regexp(email,'@', 'split');
parts is a two element cell array similar to mtrw's implementation of textscan. Maybe overkill, but regexp is much more useful when splitting a string by multiple delimiting characters or pattern searching. The only downside is the use of regular expressions which I still haven't mastered after 15 years of coding.