🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #604

Re: Regular expressions to parse an INI file, anyone?

#604
From: Jon Shemitz
Date: Mon, 28 Jun 2004 18:56
22 lines
1654 bytes
> However, I can't seem to get any regular expression working that would
> pick out all the key=value pairs for me, from a given section. I
> figured I'd just search for the "[section]" token, and then grab
> anything up to the next "[" character - but I can't seem to get that
> working.....

static string Section(string IniFile, string Name)
{
	string Pattern = @"\[" + Name + @"\]([^\[]*)\[";
	Regex GetSection = new Regex(Pattern, 
		RegexOptions.None);
	Match M = GetSection.Match(IniFile);
	if (M.Success)
		return M.Groups[1].Value;
	else
		return "";
}

-- 

programmer, author  http://www.midnightbeach.com
and father          http://www.midnightbeach.com/hs
Technical Details
Message-ID: <40E069E0.24E65246@midnightbeach.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <o210e0p6e7ndrqh72tighb6bunr7c1vunk@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,482ddbe19fa3a83b
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
Message-ID: <40E069E0.24E65246@midnightbeach.com>
Date: Mon, 28 Jun 2004 11:56:32 -0700
From: Jon Shemitz <jon@midnightbeach.com>
Reply-To: jon@midnightbeach.com
Organization: Midnight Beach
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
X-Accept-Language: en-US,en
MIME-Version: 1.0
Newsgroups: borland.public.csharpbuilder.language.csharp
Subject: Re: Regular expressions to parse an INI file, anyone?
References: <o210e0p6e7ndrqh72tighb6bunr7c1vunk@4ax.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 63.249.65.27
X-Trace: newsgroups.borland.com 1088448995 63.249.65.27 (28 Jun 2004 11:56:35 -0700)
Lines: 22
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail