Because regex is greedy by default. That is, the expressions .* Or .+ Try to take as many characters as possible. Therefore, <.+> Will span from the first < to the last > . Make lazy using a lazy operator ? :
regexp_replace(teststring, '<.+?>')
or
regexp_replace(teststring, '<.*?>')
Now the search > will be stopped at the first encounter > .
Please note that . also includes > , so the greedy option (without ? ) swallows everything > , but the latter.
source share