Add stripHTMLTags
This commit is contained in:
13
snippets/stripHTMLtags.md
Normal file
13
snippets/stripHTMLtags.md
Normal file
@ -0,0 +1,13 @@
|
||||
### stripHTMLTags
|
||||
|
||||
Removes HTML/XML tags from string.
|
||||
|
||||
Use a regular expression to remove HTML/XML tags from a string.
|
||||
|
||||
```js
|
||||
const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');
|
||||
```
|
||||
|
||||
```js
|
||||
stripHTMLTags('<p><em>lorem</em> <strong>ipsum</strong></p>'); // 'lorem ipsum'
|
||||
```
|
||||
Reference in New Issue
Block a user