Find the string that meets the conditions and delete it?

the way I write now is:

$("p span").text("");

you can delete the contents of p and span
but how to add conditions?

if you find such string span
indexOf ("instagram.com/p/")

plus it would be better if you could delete the whole span .
are there any legal facts?

Jul.27,2021

$("span:contains('instagram.com/p/')").remove()
Menu