フィルターのクリア

how i can take part of email address

2 ビュー (過去 30 日間)
Mohamuud hassan
Mohamuud hassan 2015 年 5 月 18 日
編集済み: per isakson 2015 年 5 月 18 日
hello all; if i want to take part of email address. for instance, baashe@hotmail.com, suppose i want after @, which means hotmail.com. help me to solve this

採用された回答

per isakson
per isakson 2015 年 5 月 18 日
編集済み: per isakson 2015 年 5 月 18 日
... and with regexp
>> regexp( 'baashe@hotmail.com', '(?<=@).+$', 'match' )
ans =
'hotmail.com'

その他の回答 (2 件)

Geoff Hayes
Geoff Hayes 2015 年 5 月 18 日
abdulkarim - you can use strfind or regexp. If the former you could do something like
eAddr = 'baashe@hotmail.com';
idx = strfind(eAddr,'@');
if ~isempty(idx)
domain = eAddr(idx+1:end);
end
  1 件のコメント
Mohamuud hassan
Mohamuud hassan 2015 年 5 月 18 日
thank you Hayes. how i can use regexp.

サインインしてコメントする。


Image Analyst
Image Analyst 2015 年 5 月 18 日
Use strfind(). Be sure to make your code robust enough to handle missing @ symbols, and check if @ is in there with isempty.
email = 'baashe@hotmail.com'
atIndex = strfind(email, '@');
if ~isempty(atIndex)
% It's a valid address. Extract the domain.
domain = email(atIndex+1:end);
message = sprintf('The domain is %s', domain);
uiwait(helpdlg(message));
else
% Not a proper email address.
warningMessage = sprintf('%s is not a proper email address', email);
uiwait(warndlg(warningMessage));
end

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by