<div id="0000000000000asd">id1</div>
<div id="asd0000000000000">id2</div>
<div id="000000asd0000000">id3</div>
<div id="0000000000000">id4</div>
<div class="d42342342342asd">class1</div>
<div class="asdd42342342342">class2</div>
<div class="d42342asd342342">class3</div>
<div class="d42342342342">class4</div>
<script>
let items = document.querySelectorAll('[class*=asd], [id*=asd]');
for (var i = items.length - 1; i >= 0; i--) {
items[i].remove();
}
// id4, class4
</script>