Regular Expressions 101

Community Patterns

Community Library Entry

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 - a year ago