Please tell me how to replace the a tag with regularities

Please tell me how to regularly replace the < "> of a tag with @-sharp $without affecting a href links and other tags
it is not allowed to extract and replace a tag alone

<div>
    <div class="bt">2222</div>
    <ul>
        <li>1</li>
        <li>2</li>
    </ul>
    <a href="https://segmentfault.com">ok</a>
</div>

result:

    <div>
        <div class="bt">2222</div>
        <ul>
            <li>1</li>
            <li>2</li>
        </ul>
        @a href=-sharp https://segmentfault.com -sharp $ ok @/a$
        @a href=-sharp https://segmentfault.com -sharp $ acb @/a$
        @a href=-sharp https://segmentfault.com -sharp $ 123 @/a$
    </div>
Php
May.06,2022

fdfds
    </a>
</div>';

$s = preg_replace('/<a([\s\S]*?)href="([\s\S]*?)"([\s\S]*?)>([\s\S]*?)<\/a>/', '@a${1}href=-sharp${2}-sharp${3}\$${4}@\/a\$', $s);

it should be like this. If you need a space, you can add it to the appropriate place depending on the situation

Menu