本文介绍了电子名片4.0手机正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想读电子名片4.0文件。
I want to read VCard 4.0 file .
我用这个样本。
但是当我用这个解决方案文件。
but when I use this solution for this file.
BEGIN:VCARD
VERSION:4.0
N:Gump;Forrest;;;
FN: Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO:http://www.example.com/dir_photos/my_photo.gif
TEL;TYPE=work,voice;VALUE=uri:tel:+1-111-555-1212
TEL;TYPE=home,voice;VALUE=uri:tel:+1-404-555-1212
ADR;TYPE=work;LABEL="42 Plantation St.\nBaytown, LA 30314\nUnited States of America"
:;;42 Plantation St.;Baytown;LA;30314;United States of America
EMAIL:[email protected]
REV:20080424T195243Z
END:VCARD
没有找到手机的参数 - 比如,我用这个正则表达式的电话号码:
it doesn't find Phone parameter - for example, I use this Regex for a phone number:
RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace;
regex = new Regex(@"(\n(?<strElement>(TEL)) (;*(?<strAttr>(HOME|WORK)))* (;(?<strType>(VOICE|CELL|PAGER|MSG|FAX)))* (;(?<strPref>(PREF)))* (;[^:]*)* (:(?<strValue>[^\n\r]*)))", options);
mc = regex.Matches(s);
if (mc.Count > 0)
{
Phones = new Phone[mc.Count];
for (int i = 0; i < mc.Count; i++)
{
m = mc[i];
Phones[i].number = m.Groups["strValue"].Value;
ss = m.Groups["strAttr"].Value;
if (ss == "HOME")
Phones[i].homeWorkType = HomeWorkType.home;
else if (ss == "WORK")
Phones[i].homeWorkType = HomeWorkType.work;
if (m.Groups["strPref"].Value == "PREF")
Phones[i].pref = true;
ss = m.Groups["strType"].Value;
if (ss == "VOICE")
Phones[i].phoneType = PhoneType.VOICE;
else if (ss == "CELL")
Phones[i].phoneType = PhoneType.CELL;
else if (ss == "PAGER")
Phones[i].phoneType = PhoneType.PAGER;
else if (ss == "MSG")
Phones[i].phoneType = PhoneType.MSG;
else if (ss == "FAX")
Phones[i].phoneType = PhoneType.FAX;
}
}
但strAttr,strType空值。
but value of strAttr,strType in empty.
如何设置的正则表达式这些?
How to set Regex for these?
推荐答案
而不是一个普通的前pression尝试电子名片类库,我发现它在谷歌:
Instead of a regular expression try vCard Class Library, I found it on google:
http://www.thoughtproject.com/Libraries/vCard/index.htm
这篇关于电子名片4.0手机正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!