Finding a specific character in a string in Matlab

前端 未结 7 1259
闹比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:27

    You can use strread:

    str = 'johndoe@hotmail.com';
    [a b] = strread(str, '%s %s', 'delimiter','@')
    a = 
        'johndoe'
    b = 
        'hotmail.com'
    

提交回复
热议问题