how to assign an id to every with a specific bit of text inside?

For example turning every <p>thing to assign id to</p> in the document into <p id="something">thing to assign id to</p>

this is my first question so pls point out anything I should include

I have not tried anything yet because I dont know how to do it.