Try the following:
<div[^>]*>.*?</div>
or if you just want divs with class="ex" as above
<div class="ex">.*?</div>
Edit: if you want to have more attributes in your div except the class, but want to make sure that it is a specific class, you can do it like this:
<div[^>]*?class="ex"[^>]*>.*?</div>
This will fit all below:
<div class="ex">blah blah</div> <div class="ex" id="blah">blah blah</div> <div id="foo" class="ex">blah blah</div> <div id="foo" class="ex" style="bar">blah blah</div>
I am just re-reading your question, and it seems you are trying to replace only what is inside the element, not the whole element. If you want to do this, you can do it as follows:
Find what: (<div[^>]*?class="ex"[^>]*>).*?(</div>)
Replace with: $1replaced$2
Now all your ex divs will only contain "replaced"
source share