
My recommended regular expression, which will allow text after the, will not match (.*).*$ To fix this, move the (?-s) to the beginning of the pattern, instead of after the amigo-paragraph. … where it would find 1 occurrence, when there are really four. This can be seen with the example data here: My mother is at home.

If you really meant to match it, even when more stuff comes after the on the same line, then you should use. >*$: Also, because of the $ anchor immediately after the 0-or-more >, then nothing – no whitespace, no nothing – will be allowed after the at the end of the line. *$: this matches the literals, followed by end of line. (?s) and (?-s) are opposites: by having one followed by the other, this turns on “dot matches newline” then immediately turns off “dot matches newline”. By turning off “dot matches newline” with (?-s), then it would only match when the occurs on the same line as the amigo-paragraph.

The reason why adding the (?-s) worked for you: originally, you had set “dot matches newline” using (?s), so your (.*) greedily matched everything (including newlines) from start of the first amigo-paragraph to the last line-ending- that it found.
