Add ?
after the quantifier to make it ungreedy. In this case, your regex would be .*?\n
.
To specifically match the line beginning with "Overview: ", use this regex:
/^Overview:\s.*$/im
The m
modifier allows ^
and $
to match the start and end of lines instead of the entire search string. Note that there is no need to make it ungreedy since .
does not match newlines unless you use the s
modifier - in fact, making it ungreedy here would be bad for performance.