Parsing key-value entries from Windows .INI files


How to write a regular expression to parse key-value entries from Windows .INI files?

Here is an example Windows .INI file, system.ini:



Here is a regular expression to parse file entries from output of the "dir" command on Windows systems: with multiple lines modifier "m": Note that:

(\s*(.+?)\s*=   - capture the key name before '='
=\s*(.+)        - capture the value after '=' and excluding '#'

Click the button to test this regular expression here online:

2013-02-01, 4477👍, 0💬