There are cases where you might need to limit the multiple replacements that SiteSpect would do to a specific section of page source
Let's say you have a page that looks like:
.
.
.
<body>
<div>some content</div>
<img src="/path0">
<div id="contentWrapper">
<img src="/path1">
<img class="someclass" src="/path2">
</div>
<div id="new">Hello</div>
<img src="/path3">
<div>some content</div>
</body>
</html>
And you want to add a class to the images that are within the contentWrapper div. Regex can be used to limit the scope of search and replace by using look aheads - one negative and one positive.
Consider a search
<img(?!.*<div id="contentWrapper">)(?=.*<div id="new")
which effectively says match on the <img string while <div id="contentWrapper"> is not after and <div id="new" is after.
So the replace might be
<img class="lazy-load"
but it will be limited to the two img tags in the contentWrapper div