Fixed subsection replacement with before/after patterns
Fixed subsection replacement with before/after patterns

* using a _named_ capture in our assembled pattern, since before/after could potentially contain their own parenthesized captures
* ensuring we only replace against the named capture in question
* removing some duplication in the regexp replacement, that was introduced in ansible/ansible#22535
* fixed edge case of before/after not matching file content to replace

Fixes ansible/ansible#24840

thaim/ansible,thaim/ansible