Skip to content

Instantly share code, notes, and snippets.

@JoelHough
Created February 12, 2014 18:29
Show Gist options
  • Save JoelHough/8961630 to your computer and use it in GitHub Desktop.
Save JoelHough/8961630 to your computer and use it in GitHub Desktop.
ugly but faster regex

with the (probably useless) \w-\w clause removed, making the regex: /\A([-:,\;#%.\(\)\/\sa-zA-Z0-9!]|\'[\s\w]+\'|\"[\s\w]+\"|\([\d,\s]+\))*\z/

>> Benchmark.measure{ Sanitize.clean(<<TEXT, WikiPage.fully_sanitize_fields_config[:body]) }
 | <span lang="EN" style="font-family: 'Times New Roman','serif'; color: #17375e; font-size: 12pt; mso-fareast-font-family: 'Times New Roman'; mso-themecolor: text2; mso-themeshade: 191; mso-style-textfill-fill-color: #17375E; mso-style-textfill-fill-themecolor: text2; mso-style-textfill-fill-alpha: 100.0%; mso-ansi-language: EN; mso-style-textfill-fill-colortransforms: lumm=75000"><p></p></span>
 | TEXT
=>   0.000000   0.000000   0.000000 (  0.003236)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment