Test, validate and match regular expressions
Matches variable declarations using a bracketed placeholder syntax like `var[%name%]`, optionally followed by an assignment `= value` on the same line. Group 1 captures the word-character key inside `[% %]`, and group 2 captures the assigned value with whitespace around the `=` and trailing whitespace trimmed (value must end with a non-whitespace character). It uses `[^\S ]` to match horizontal whitespace only, keeping it Python re compatible. Ideal for parsing custom template or config DSLs line by line.