<?php
$str ="test Приходите в наш <a d>test</a> видеочат, бывший когда-то test'м.testa больше нет. Забейте на <h2>test</h3> Труконф test";
echo preg_replace('/<[ah][^>]*>(*SKIP)(test)/', '<$0>', $str);
echo preg_replace('/a{3}(*SKIP)c/', '<$0>', 'aaaac');
Warning: preg_replace(): Compilation failed: nothing to repeat at offset 12 in /in/C7tpU on line 4
Warning: preg_replace(): Compilation failed: nothing to repeat at offset 5 in /in/C7tpU on line 5
Output for 4.3.0 - 4.3.10
Warning: Compilation failed: nothing to repeat at offset 12 in /in/C7tpU on line 4
Warning: Compilation failed: nothing to repeat at offset 5 in /in/C7tpU on line 5