Skip to content

Instantly share code, notes, and snippets.

@Zetaphor
Created January 24, 2017 03:45
Show Gist options
  • Save Zetaphor/97dabc982abdbc940998aa455fc4fa41 to your computer and use it in GitHub Desktop.
Save Zetaphor/97dabc982abdbc940998aa455fc4fa41 to your computer and use it in GitHub Desktop.
const regex = /^(?:https?:\/\/w*\.?)?([a-zA-Z0-9\.\-_]+)(?:[\/.\-_a-zA-Z0-9]*)$/;
const str = `https://test.google.com/testdsadsa`;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment