rickyah / ini-parser

Read/Write an INI file the easy way!
MIT License
971 stars 241 forks source link

Multiple comment character #115

Open Malij75 opened 8 years ago

Malij75 commented 8 years ago

Hi,

Standard ini file allow to use for comment line both "#" and ";" as comment char, but current version not supported multiple comment char.

Possible solution: add [] in _strCommentRegex in IniParserConfiguration.cs like: protected const string _strCommentRegex = @"^[{0}](.*)";

Regard, Andriy

Malij75 commented 8 years ago

This solution fix also a bug if you try to use "[", "]" , "(", ")" etc. as comment string

Regard, Andriy

caverna commented 8 years ago

@Malij75 did you try Configuration.CommentRegex option?

Malij75 commented 7 years ago

Hi, yes i try to use Configuration.CommentRegex, but if you format strCommentRegex @"^{0}(.)" and replase {0} with configured comment string "#;" will result in regex "^#;(._)" and test for string ";comment will be fail. Right pattern is "^#;"

if you use "[" as a comment string then pattern for comment regex "^[(.)" is wrong. Right pattern is "^[[](.)"

rickyah commented 7 years ago

I think I didn't considered using multiple comment characters. I'll take a look at your improvements, thanks

Lumary2 commented 3 years ago

Hi I found a regex that works for C#: parser.Configuration.CommentRegex = new Regex(@"(#|;)(.*)");