.DS_Store
# regex-in-javascript
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Javascript Regular Expressions: Find Repeated Patterns</title>
  <style>
    pre {
      line-height: 2;
    }

    span {
      background-color: #eee;
      padding: 1px;
      outline: 1px solid #999;
    }
  </style>
</head>
<body>
  <script>
    // Allows Plunker to display logs in preview panel 
    // for better in-browser experience
    var originalConsoleLog = console.log
    console.log = function () {
      originalConsoleLog.apply(console, arguments)
      var args = Array.prototype.slice.call(arguments);
      document.body.innerText += args.join(' ') + '\n';
      document.body.style['fontFamily'] = 'monospace';
      document.body.style['fontSize'] = '2em';
    };
  </script>

  <pre></pre>
  <script src="script.js"></script>
</body>
</html>
'use strict';

var str = `http://egghead.io
not a web address
http://
https://egghead.io more`;
var regex = /https?:\/\/.+/g

/**
 * @param  String str
 * @param  RegExp regex
 * @param  HTMLElement target
 */
const output = (str, regex, target) => {
  target.innerHTML =
    str.replace(regex, str =>
      `<span>${str}</span>`
    );
}
output(str, regex, document.querySelector('pre'));