Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Regexps can be fast, but they don't have to

mrzasa
March 17, 2018

Regexps can be fast, but they don't have to

LIghtning talk about regexp performance pitfalls in Ruby and browser. Wroclove.rb 2018

mrzasa

March 17, 2018
Tweet

More Decks by mrzasa

Other Decks in Programming

Transcript

  1. REGEXPS CAN BE REGEXPS CAN BE FAST FAST BUT THEY

    DON'T HAVE TO BUT THEY DON'T HAVE TO MACIEK RZĄSA, TEXTMASTER MACIEK RZĄSA, TEXTMASTER @mjrzasa
  2. 100% CPU ON PRODUCTION 100% CPU ON PRODUCTION Hello! →

    Witaj! → ¡Hola! → Salut ! Discourse client, described by Sam Saffron ::Typography.to_html_french # Insert a thin space before punctuation text.gsub(/(\s|)+([!?;]+(\s|\z))/, '&thinsp;\2\3') # <-58 spaces> GET /wp-login.php HTTP/1.1 69 GET /show.aspx HTTP/1.1 15
  3. WHAT COULD I DO? WHAT COULD I DO? be specific

    test almost matching input don't believe in magic, there is just software I will send links on twitter