I want to generate regex for vCard Properties.

For Ex:

VERSION:

Regex regex = new Regex(@"(?<strElement>(VERSION))   (:(?<strVERSION>[^\n\r]*))", options);
 Match  m = regex.Match(s);

how to write other vcard proparty like ADR,AGENT,PHOTO,ETC...

http://en.wikipedia.org/wiki/VCard#hCard_1.0

有帮助吗?

解决方案

For such straightforward format it is better to avoid regexps and use simple string operations. For example, the text can be splited by \n and then each line can be splited by semicolon.

If you want to continue with regexps, try to replace VERSION with \w+ and " " with " *". I also not sure that the second grouping is necessary. Also, the ^ and $ can be added (the multiline regex option should be used then):

@"^(?<strElement>(\w+)) *:(?<strVERSION>.*)$"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top