Skip to content

Instantly share code, notes, and snippets.

@FGRibreau
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FGRibreau/af15e1fd9406af644e3a to your computer and use it in GitHub Desktop.
Save FGRibreau/af15e1fd9406af644e3a to your computer and use it in GitHub Desktop.
Regex to hang on V8 engine (Chrome/NodeJS)
// The following script will hang on V8 regex engine. (It works fine on Safari Mac).
// Regex was taken from https://gist.github.com/gruber/249502
"http://www.ghislainproulx.net/Blog/2014/09/contributing-to-a-github-open-source-project-(from-a-visual-studio-developer-perspective)".replace(/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi, function(url){
// this will never be executed on Chrome/Node
console.log(url);
});
// Checkout your CPU consumption !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment