从电子邮件中删除其他字符串 [英] remove of additional string from email
本文介绍了从电子邮件中删除其他字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个文本框,我正在传递邮件ID,如mohd.wasif@virtuosoitsolutions.com
.现在的事情是,我只希望从电子邮件中获取mohd.wasif,并希望在@ virtuosoitsolutions.com之后删除字符串.请让我知道如何从邮件中删除@之后的字符串.
谢谢.
Mohammad Wasif
Hi All,
I have a Textbox in that I am passing mail id like mohd.wasif@virtuosoitsolutions.com
. Now the thing is this i want only mohd.wasif from email and want to remove string after @virtuosoitsolutions.com. Please let me know how to remove string after @ from mail.
Thanking You.
Mohammad Wasif
推荐答案
String mailId = "mohd.wasif@virtuosoitsolutions.com";
mailId = mailId.Trim();
int positionOfAtSign = mailId.IndexOf('@');
String firstPart = (positionOfAtSign<0) ? mailId : mailId.Substring(0,maildId.IndexOf("@"));
祝您编程愉快!
Happy coding!
mail.Remove(mail.IndexOf("@"), mail.Length - mail.IndexOf("@"));
我最喜欢拆分.
I like split the best.
string eMail = "mohd.wasif@virtuosoitsolutions.com";
string[] parsed = eMail.Split(''@'');
string emailID = parsed[0];
string emailServer = parsed[1];
这也将允许您验证正确的服务器空间:D
This will allow you to validate the correct server space also :D
这篇关于从电子邮件中删除其他字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文