Skip to content

Instantly share code, notes, and snippets.

@pashagray
Created April 6, 2016 06:26
Show Gist options
  • Save pashagray/d0cdaed89f51f763e3a62a94958295ae to your computer and use it in GitHub Desktop.
Save pashagray/d0cdaed89f51f763e3a62a94958295ae to your computer and use it in GitHub Desktop.
bad_string = 'esdfd((esdf)(esdf'
bad_string.split('').each_with_index.map { |char, idx| [char, idx] if char == '(' || char == ')' }.compact
#=> [["(", 5], ["(", 6], [")", 11], ["(", 12]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment