Finding a specific character in a string in Matlab

前端 未结 7 1256
闹比i
闹比i 2020-12-16 13:02

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

7条回答
  •  太阳男子
    2020-12-16 13:21

    STRTOK and an index operation should do the trick:

    str = 'johndoe@hotmail.com';
    [name,address] = strtok(str,'@');
    address = address(2:end);
    

    Or the last line could also be:

    address(1) = '';
    

提交回复
热议问题