如果有一段文本如下:
sdfa;阿斯顿发生大幅@@@@@@,[email protected],和[email protected],的说法的发生的发生大幅[email protected]
我要取出电子邮件:[email protected],[email protected],[email protected],[email protected]
总之,文本的内容是不可预知的,我要取出所有的电子邮件地址
sdfa;阿斯顿发生大幅@@@@@@,[email protected],和[email protected],的说法的发生的发生大幅[email protected]
我要取出电子邮件:[email protected],[email protected],[email protected],[email protected]
总之,文本的内容是不可预知的,我要取出所有的电子邮件地址
解决方案 »
- windows server 2003 winform中的System.Timers.Timer不被触发
- VS2010里面Team Foundation Server用户连接的问题
- Visual C#速成版
- 时间中的参数EventArgs e 为什么e没有 .row 属性?如何拥有row属性?
- 跪求支持CDMA Modem的短信发送和接收程序
- 关于.NET中选取文件的对话框的问题
- ArrayList问题,有时候居然会搜索不到
- 请问.NET中相应键盘事件的模式是何种模式
- VS2005+水晶报表,编译时出现602个警告,请问如何清除?
- C#按钮事件问题,求大神
- 通过webBrowser如何修改其中的HTML页面
- 求C#得到本机所在的域的其他方法
取出匹配的字符串就可以了..
楼主试试
\. = .
| = 或
符合 [email protected] 或 符合 [email protected] 的形式的满足条件
[email protected]
如果要是这样的一个文本,你怎么取,
我说我信箱是[email protected] 前面和后面你怎么判断,
我说我信箱是[email protected] 又怎么判断,
这个没有限制,怎么找到@前的信箱名?
我觉得无解。
看楼下的吧。
我们是不是要把 cn en 等国家代号都取出来?
[email protected]
cns 是一个国家名 这个 ~~?
把数据拷贝到这个文件。sdfa;阿斯顿发生大幅@@@@@@,[email protected],和[email protected],的说法的发生的发生大幅[email protected]点排序按钮,选择“比较由正则表达式定义的字符串”,输入下面的正则表达式和目标字符串:
正则表达式:[a-z|A-Z|0-9|_.]+@[a-z|A-Z|0-9|_.]+[|!a-z|!A-Z|!0-9|!_.]?
目标字符串:%01%02%03;点“将目标字符串拷贝到剪贴板”,即可将你要的邮箱地址拷贝到剪贴板:
[email protected];[email protected];[email protected];[email protected];
int nMailEndIndex = -1;
int nEmailSignIndex = -1;
BOOL bEmailSignExists = FALSE; //@ exists or notfor(int i = 0; i < sInput.GetLength(); i++)
{
TCHAR tcharCurrent = sInput.GetAt(i);
if( (tcharCurrent >= _T('0') && tcharCurrent <= _T('9')) ||
(tcharCurrent >= _T('a') && tcharCurrent <= _T('z')) ||
(tcharCurrent >= _T('A') && tcharCurrent <= _T('Z')) ||
(tcharCurrent == _T('.') || tcharCurrent == _T('_') || tcharCurrent == _T('-'))
)
{
if(nMailStartIndex < 0)
{
nMailStartIndex = i;
}
}
else if(tcharCurrent == _T('@'))
{
if(nMailStartIndex >=0 && nMailStartIndex < i)
{
bEmailSignExists = TRUE;
nEmailSignIndex = i;
}
}
else
{
//当前字符不是邮件地址可能的字符,如果邮件开始地址存在并且“@“存在,并且@两边都存在合法的字符串,
//我们把当前字符作为结束符并输出邮件地址。
if(nMailStartIndex >= 0 && bEmailSignExists && nEmailSignIndex < i - 1)
{
TRACE(sInput.subString(nMailStartIndex, i - 1));
}
//重新设置标记
nMailStartIndex = -1;
nMailEndIndex = -1;
nEmailSignIndex = -1;
bEmailSignExists = FALSE;
}
}
int nMailEndIndex = -1;
int nEmailSignIndex = -1;
BOOL bEmailSignExists = FALSE; //@ exists or notfor(int i = 0; i < sInput.GetLength(); i++)
{
TCHAR tcharCurrent = sInput.GetAt(i);
if( (tcharCurrent >= _T('0') && tcharCurrent <= _T('9')) ||
(tcharCurrent >= _T('a') && tcharCurrent <= _T('z')) ||
(tcharCurrent >= _T('A') && tcharCurrent <= _T('Z')) ||
(tcharCurrent == _T('.') || tcharCurrent == _T('_') || tcharCurrent == _T('-'))
)
{
if(nMailStartIndex < 0)
{
nMailStartIndex = i;
}
}
else if(tcharCurrent == _T('@'))
{
if(nMailStartIndex >=0 && nMailStartIndex < i)
{
bEmailSignExists = TRUE;
nEmailSignIndex = i;
}
}
else
{
//当前字符不是邮件地址可能的字符,如果邮件开始地址存在并且“@“存在,并且@两边都存在合法的字符串,
//我们把当前字符作为结束符并输出邮件地址。
if(nMailStartIndex >= 0 && bEmailSignExists && nEmailSignIndex < i - 1)
{
TRACE(sInput.subString(nMailStartIndex, i - 1));
}
//重新设置标记
nMailStartIndex = -1;
nMailEndIndex = -1;
nEmailSignIndex = -1;
bEmailSignExists = FALSE;
}
}
int nMailEndIndex = -1;
int nEmailSignIndex = -1;
BOOL bEmailSignExists = FALSE; //@ exists or notfor(int i = 0; i < sInput.GetLength(); i++)
{
TCHAR tcharCurrent = sInput.GetAt(i);
if( (tcharCurrent >= _T('0') && tcharCurrent <= _T('9')) ||
(tcharCurrent >= _T('a') && tcharCurrent <= _T('z')) ||
(tcharCurrent >= _T('A') && tcharCurrent <= _T('Z')) ||
(tcharCurrent == _T('.') || tcharCurrent == _T('_') || tcharCurrent == _T('-'))
)
{
if(nMailStartIndex < 0)
{
nMailStartIndex = i;
}
}
else if(tcharCurrent == _T('@'))
{
if(nMailStartIndex >=0 && nMailStartIndex < i)
{
bEmailSignExists = TRUE;
nEmailSignIndex = i;
}
}
else
{
//当前字符不是邮件地址可能的字符,如果邮件开始地址存在并且“@“存在,并且@两边都存在合法的字符串,
//我们把当前字符作为结束符并输出邮件地址。
if(nMailStartIndex >= 0 && bEmailSignExists && nEmailSignIndex < i - 1)
{
TRACE(sInput.subString(nMailStartIndex, i - 1));
}
//重新设置标记
nMailStartIndex = -1;
nMailEndIndex = -1;
nEmailSignIndex = -1;
bEmailSignExists = FALSE;
}
}