Skip to content

Instantly share code, notes, and snippets.

@conundrumer
Created February 2, 2016 20:49
Show Gist options
  • Select an option

  • Save conundrumer/aa1ad507a529b4e2c3aa to your computer and use it in GitHub Desktop.

Select an option

Save conundrumer/aa1ad507a529b4e2c3aa to your computer and use it in GitHub Desktop.
really inefficient regex in twitch.tv's embedded chat
// The amount of time it takes for the RegEx to finish depends on the url of the current page:
var short = 'http://iridethelines.forumotion.com/post?p=183422&mode=editpost'
var medium = 'http://iridethelines.forumotion.com/t11564-threads-with-2-pages-freezing-tab#183414'
var reallyLong = 'http://iridethelines.forumotion.com/t10491p150-the-bofficial-b-chuggers-preview-thread-for-men'
var m = new RegExp("^https?://([a-zA-Z0-9]+.)*twitch.tv(:[0-9]+)?/.*$")
var t
t = Date.now(); m.test(short); console.log((Date.now() - t) / 1000)
t = Date.now(); m.test(medium); console.log((Date.now() - t) / 1000)
t = Date.now(); m.test(reallyLong); console.log((Date.now() - t) / 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment