문제

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