You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, I wanted to thank you for creating this! I needed an INI reading/writing solution for C# and this gave me a great starting point. Your C# file is quite robust. Much appreciated!
Your regular expression's logic works fine, but all subpattern names mus be unique to prevent pattern errors. I'm not sure if this causes issues for the way your c# code works, but it will cause issues if this is ever expanded to include additional subpatterrn matches in the same function where you're trying to identify them by name.
Here's the updated regular expression to get around this issue:
It's true that some regular expression languages do not allow duplicate identifiers. However, C#, like most other programming languages, does not have this problem.
First, I wanted to thank you for creating this! I needed an INI reading/writing solution for C# and this gave me a great starting point. Your C# file is quite robust. Much appreciated!
Your regular expression's logic works fine, but all subpattern names mus be unique to prevent pattern errors. I'm not sure if this causes issues for the way your c# code works, but it will cause issues if this is ever expanded to include additional subpatterrn matches in the same function where you're trying to identify them by name.
Here's the updated regular expression to get around this issue:
(?=\S)(?<text>(?<comment>(?<open_comment>[#;]+)(?:[^\S\r\n]*)(?<value>.+))|(?<section>(?<open_section>\[)(?:\s*)(?<value_section>[^\]]*\S+)(?:[^\S\r\n]*)(?<close>\]))|(?<entry>(?<key>[^=\r\n\ [\]]*\S)(?:[^\S\r\n]*)(?<delimiter>:|=)(?:[^\S\r\n]*)(?<value_entry>[^#;\r\n]*))|(?<undefined>.+))(?<=\S)|(?<linebreaker>\r\n|\n)|(?<whitespace>[^\S\r\n]+)
And here it is in regex101: https://regex101.com/r/x37Qua/1
The text was updated successfully, but these errors were encountered: