Skip to main content
GameDev.net gamedev.net
🔒 Locked

Need C# Regular Expression help

Started by darkcypher543 Jan 7, 2007 at 7:22 PM 1 replies 550+ views
Original Post
darkcypher543
darkcypher543
I'm working on a simple ConfigurationManager class in C# for my game engine. The format of the config file is similar to that of INI files. Here is a sample line from my config file:
Quote:
[screen.resolution] 800x600
The key name (enclosed in [ and ]) should not contain spaces. Only lower-case a-z, 0-9, and periods. Multiple spaces OR tabs should follow the key name, and the key value may contain anything except tabs. I'm horrible with regular expressions, especially C# regex, because I don't know it very well and most of the sites that talk about it are very confusing. Can anyone tell me what the regular expression would be for that? Also, is it possible to extract information from a regular expression using the Regex class? I would like to extract the key name and key value, so I may use it somewhere else. Thanks!
TheTroll
TheTroll
Just a thought, why not use an XML file for your configuration file. You can XMLSeralize the data into the file and get it out the same way.
darkcypher543
darkcypher543
XML seems like too much for me. My game uses simple configuration options, so I figured I should use a simple configuration format like INI files. But, I wanted to write my own format instead of using something generic. I never really could jump on the XML bandwagon, anyway.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.