ini-parser icon indicating copy to clipboard operation
ini-parser copied to clipboard

Multiple comment character

Open Malij75 opened this issue 9 years ago • 5 comments

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 avatar Sep 07 '16 15:09 Malij75

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

Regard, Andriy

Malij75 avatar Sep 08 '16 08:09 Malij75

@Malij75 did you try Configuration.CommentRegex option?

caverna avatar Oct 12 '16 17:10 caverna

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 "^["

Malij75 avatar Nov 08 '16 10:11 Malij75

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

rickyah avatar Nov 16 '16 11:11 rickyah

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

Lumary2 avatar Sep 16 '21 09:09 Lumary2