Regular Expressions 101

Community Patterns

INI Parser

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^[^\S\r\n]* (?: \s* (?<section>\[[^\]]*\]) [^\S\r\n]* (?<comment>(?:[#;].*)?) | (?<comment>(?:[#;].*)?) | (?: (?<key>[^#;]+?) \s* = [^\S\r\n]* (?: (?: "(?<value_quote>.*)" | (?<value>(?:[^#;\r\n\\\s]*[\s]??(?:\\.)*)*) ) [^\S\r\n]* (?<comment>(?:[#;].*)?) ) ) | (?<error>.*) ) $
/
iJxmg

Description

  • comments
  • section
  • key = value
  • key =
  • ltrim
Submitted by foul11, raxdiam - 7 months ago