Skip to content

Instantly share code, notes, and snippets.

@abrjagad
Last active October 6, 2018 04:50
Show Gist options
  • Select an option

  • Save abrjagad/1cd92cd3960a84efc1bf737c13a99d6d to your computer and use it in GitHub Desktop.

Select an option

Save abrjagad/1cd92cd3960a84efc1bf737c13a99d6d to your computer and use it in GitHub Desktop.

Revisions

  1. Abraham Jagadeesh revised this gist Oct 6, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion strip_html.js
    Original file line number Diff line number Diff line change
    @@ -13,5 +13,8 @@ var a = `<!DOCTYPE html>
    <div class="example">See you</div>
    </body>
    </html>`
    //regex from Csstricks.com
    a.replace(/(<([^>]+)>)/ig,"").replace(/[\n]{1,}/gi,'').split(' ').filter(String);

    a.replace(/(<([^>]+)>)/ig,"").replace(/[\n]{1,}/gi,'').split(' ').filter(String)
    // prints
    // ["Document", "Hello", "World", "Hi", "Guys", "You", "are", "awesome", "See", "you"]
  2. Abraham Jagadeesh created this gist Oct 6, 2018.
    17 changes: 17 additions & 0 deletions strip_html.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    var a = `<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    </head>
    <body>
    <a href="1.html">Hello World</a>
    <a href="2.html">Hi Guys</a>
    <a href="3.html">You are awesome</a>
    <div class="example">See you</div>
    </body>
    </html>`

    a.replace(/(<([^>]+)>)/ig,"").replace(/[\n]{1,}/gi,'').split(' ').filter(String)