필터 지우기
필터 지우기

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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by