Skip to content

Instantly share code, notes, and snippets.

@adamloo85
Created November 14, 2013 06:53
Show Gist options
  • Save adamloo85/7462551 to your computer and use it in GitHub Desktop.
Save adamloo85/7462551 to your computer and use it in GitHub Desktop.
Method to determine if a string has a valid representation of "(...)". Ex: "((...)" would return "false"
def nested?(string)
string.gsub!(/[^()]/, '')
string.gsub!(/\(\)/, '')
string.empty?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment