How to replace all the <td> and <td> first lines with <th> and </th> respectively, leaving intact what is inside the tags (text). I know that there is such a thing as .replace() , but I do not quite understand how to use it in this situation. Interested in a turnkey solution that allows you to change the type str
"<tr><td>1</td><td>2</td><td>3</td></tr>" replaced by
"<tr><th>1</th><th>2</th><th>3</th></tr>" The number of cells can be arbitrary. Thank you in advance.