I think I understand the situation (Q5).
When you “extract all”, only the first line of the matched string will be extracted. Since your search term was “\nSetEnvironment”, you are extracting each line before “SetEnvironment”. Therefore, the result was correct.
However, I am not sure about Q6.