Here is a way using the BOL.
`(?m)^if.*\R+(?:^[\t ]+.*\R+)*?^[\t ]+test\.check\(\).*\R?`
https://regex101.com/r/WR9JtI/1
(?m) ^ if .* \R+ (?: ^ [\t ]+ .* \R+ )*? ^ [\t ]+ test \. check \( \) .* \R?