Skip to content

Instantly share code, notes, and snippets.

View tannermares's full-sized avatar

Tanner Mares tannermares

View GitHub Profile
@tannermares
tannermares / benchmark.rb
Last active November 27, 2024 20:06
ruby regex w/lookahead benchmarks
require 'benchmark'
require 'nokogiri'
content = "#{'<div class="test" style="margin:10px;">' * 450}<p>Deep content</p>#{'</div>' * 450}"
DUPLICATE_NESTED_DIV_LOOKAHEAD_REGEX = %r{
(?<outer_div>
<div(?<attrs>[^>]*)>\s* # Match the outermost <div> with its attributes
(?:<div\k<attrs>>\s*)* # Match zero or more nested identical <div>
(?<inner_div><div\k<attrs>>.*?</div>) # Match the innermost <div> and its content
@tannermares
tannermares / keybase.md
Last active June 16, 2016 21:44
I am who I am.

Keybase proof

I hereby claim:

  • I am tannermares on github.
  • I am tannermares (https://keybase.io/tannermares) on keybase.
  • I have a public key whose fingerprint is 3FBA 442C 9A25 3252 8749 A942 BF69 9954 767E 298D

To claim this, I am signing this object: