Last active
August 22, 2016 18:42
-
-
Save jgnagy/ece787b05237b9e8051180cfcdfc55e8 to your computer and use it in GitHub Desktop.
This file contains 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
tab_count = 0 | |
File.readlines('/path/to/file').each do |line| | |
# The regexp looks for 1 or more tabs at the beginning of the line as a group. | |
# We then split the result by character, then get the size of the Array from the split. | |
# Only do all that if the line matches the regexp in the first place. | |
tab_count += line.match(/^([\t]+)/)[1].split('').size if line.match /^([\t]+)/ | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment