Add stripHTMLTags

This commit is contained in:
Angelos Chalaris
2018-01-26 13:56:16 +02:00
parent 427e908c45
commit 6d0c7a1d2a
2 changed files with 14 additions and 0 deletions

13
snippets/stripHTMLtags.md Normal file
View 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'
```