Created
February 27, 2011 20:56
-
-
Save xadn/846530 to your computer and use it in GitHub Desktop.
Ruby regex for stripping comments and whitespace
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
# Remove comments, whitespace, newlines, and returns | |
# Use line.gsub! to modify the actual line instead of just returning the result | |
@input = line.gsub(/\t|\s|\n|\r|\/{2}.*$/, '') | |
# Then, once all of the crap is gone make sure to skip empty lines | |
if([email protected]?) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment