0

How would I remove all <> tags from a string, and the contents within them?

<p>Hello, how are you doing <strong>today</strong></p>

to

Hello, how are you doing today

using JavaScript with Regex?

1
  • "<p>Hello, how are you doing <strong>today</strong></p>".replace(/\<[^>]+\>/g, '') Commented Mar 23, 2020 at 19:51

1 Answer 1

1

Here is how you can do it:

const input = '<p>Hello, how are you doing <strong>today</strong></p>';

const result = input.replace(/<[^>]+>/g, '');

console.log(result);

Sign up to request clarification or add additional context in comments.

2 Comments

Awesome! Thanks. Sorry Regex really confuses me with all the random symbols crammed together.
I suggest you use regex101.com which explains and helps debug regexes

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.