Re: parse string CN= OU= O=
- From: "Mark Rae [MVP]" <mark@xxxxxxxxxxxxxxxxx>
- Date: Thu, 2 Jul 2009 10:20:22 +0100
"Alhambra Eidos Development" <AlhambraEidosDevelopment@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:7E3747A8-E083-480C-9C32-8D0BE5822C9A@xxxxxxxxxxxxxxxx
Thanks, mister.
LOL! You're welcome, mate.
The problem is
CN="MAORI RAMOS, PEPE (AUTENTICACIÓN)"
Apologies, I missed that...
Below is some code that will fix that, but it's a bit of a hack - hopefully, someone else will provide a better alternative:
string strRaw = "C=ES, SERIALNUMBER=123456789R, SN=MAORI, G=PEPE, CN=\"MAORI RAMOS, PEPE (AUTENTICACIÓN)\"";
Regex objRegex = new Regex("\"((.|\n)*?)\"", RegexOptions.IgnoreCase);
foreach (Match objMatch in objRegex.Matches(strRaw))
{
string strTextInQuotes = objMatch.ToString().Trim('\"').Replace(",", "¬");
strRaw = strRaw.Replace(objMatch.ToString(), strTextInQuotes);
}
List<string> lstRaw = new List<string>(strRaw.Split(','));
Dictionary<string, string> dicRaw = new Dictionary<string, string>();
foreach (string strElement in lstRaw)
{
dicRaw.Add(strElement.Split('=')[0].Trim(), strElement.Split('=')[1].Trim().Replace("¬", ","));
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
.
- Follow-Ups:
- Re: parse string CN= OU= O=
- From: Jesse Houwing
- Re: parse string CN= OU= O=
- References:
- parse string CN= OU= O=
- From: Alhambra Eidos Development
- Re: parse string CN= OU= O=
- From: Mark Rae [MVP]
- Re: parse string CN= OU= O=
- From: Alhambra Eidos Development
- parse string CN= OU= O=
- Prev by Date: Re: Regex with time
- Next by Date: Gnostice PDFOne .NET v2.11 released
- Previous by thread: Re: parse string CN= OU= O=
- Next by thread: Re: parse string CN= OU= O=
- Index(es):
Relevant Pages
|