I am trying to remove content between <div>content</div> using QRegularExpression. When the tag occurs once, it works fine. However, when it occurs more than once, it fails.

For example

QString str( "This is a <div style='color:red;'>test</div> to remove all <div>divs</div> from html string" );

I want to remove all content between "div" tag to produce following new string

"This is a to remove all from html string".

QRegularExpression rx( "<(div)[^>]*>.*</div>", QRegularExpression::CaseInsensitiveOption ) produce new string below

"This is a from html string"

I can not use xml parser as the html may not be well formed.

Many thanks.