Created
November 14, 2013 06:53
-
-
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"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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