Permalink
Browse files

Learn regular expressions

  • Loading branch information...
1 parent 92435e9 commit f954f7d769fa53f7eed601d933213c9fcd65e3c9 @kneath committed Feb 6, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/kss/comment_parser.rb
View
@@ -8,28 +8,28 @@ class CommentParser
# Returns a boolean.
def self.single_line_comment?(line)
- !!(line =~ /[\s+]?\/\//)
+ !!(line =~ /\s*\/\//)
end
# Returns a boolean.
def self.start_multi_line_comment?(line)
- !!(line =~ /[\s+]?\/\*/)
+ !!(line =~ /\s*\/\*/)
end
# Returns a boolean.
def self.end_multi_line_comment?(line)
- !!(line =~ /[.+]?\*\//)
+ !!(line =~ /.*\*\//)
end
# Returns a String.
def self.parse_single_line(line)
- matches = line.match /([.+]?\/\/)(.+)?/
+ matches = line.match /(.*\/\/)(.+)?/
matches[2].to_s
end
# Returns a String.
def self.parse_multi_line(line)
- cleaned = line.to_s.sub(/[\s+]?\/\*/, '')
+ cleaned = line.to_s.sub(/\s*\/\*/, '')
cleaned = cleaned.sub(/\*\//, '')
cleaned
end

0 comments on commit f954f7d

Please sign in to comment.