Regular Expressions 101

Community Patterns

1...45678...15

INI Parser

1

Regular Expression
.NET 7.0 (C#)

@"
(?:(?=;|#)(?<cs>;|#)(?:[^\S\r\n]*))(?<comment>.+)(?<=\S)|(?:[^\S\r\n]*)(?<=\[)(?:[^\S\r\n]*)(?<section>\w+)(?:[^\S\r\n]*?)(?=\])|(?<entry>(?=\S)(?<key>[^\r\n;#]+)(?:[^\S\r\n]*)(?==)=(?<==)(?:[^\S\r\n]*)(?<value>.*)(?<=\S))
"
ig

Description

This regular expression has the following features that make it a convenient tool for working with text data.

  • Ignoring syntax errors The regular expression is able to ignore syntax errors whenever possible. This allows you to handle data with formatting errors without losing important information.
  • Case insensitive The expression is case insensitive, making it easier to use and more versatile.
  • Minimum number of passes Due to its structure, a regular expression allows you to process data in a minimum number of passes. This speeds up the process of data analysis and processing.
  • Independence of line break format The expression is independent of the line break format, allowing it to be used with data represented in different formats.
  • Trimming invisible characters The regular expression trims invisible characters such as spaces and tabs, making data easier to process and more readable.

This makes regular expression a useful tool for analyzing and manipulating text data. It can be used in various scenarios where efficient text processing is required.

Submitted by Pavel Bashkardin - 2 months ago (Last modified an hour ago)