Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Learn regular expressions

  • Loading branch information...
commit f954f7d769fa53f7eed601d933213c9fcd65e3c9 1 parent 92435e9
@kneath authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/kss/comment_parser.rb
View
10 lib/kss/comment_parser.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.