Convert HTML to String?

Is there any way to convert an html text element to a string that I can copy and paste? I have code like this:

let input = “TEST”
let html = “<p><b>”+input+”</b></p>”

let newHtml = 

And that’s where I’m stuck. I need some way to get “TEST” in a way that is copy-able.

I’ve tried .toString(), but that doesn’t work. Any and all help would be greatly appreciated!

The code you’ve shared above is already of type String.

So you basically want to remove all HTML elements (and, btw, HTML is a string) ? replace might help there, like

result = string.replace(/<[^>]*>/g,"");

But if your code is really anything like in the example, why don’t you simply use input?

1 Like

do you mean copy the formatted rich text instead of the plain text with HTML markups? if that’s the case, Shortcuts may be a much easier solution for you.