I would like to remove comments from a JavaScript file with a Ruby
script. I discovered that my regular expression matching seems to match
the biggest possible substring.
def show_regexp(a,re)
if a =~ re
"#{$`}<<#{$&}>>#{$'}"
else
"no match"
end
end
puts show_regexp("/* some comment */ some code /* some other comment
*/", /\/\*[\w\W]*\*\//)
This outputs
<</* some comment */ some code /* some other comment */>>
and I was hoping for it to find the individual comments.
<</* some comment */>> some code <</* some other comment */>>
I would like to remove comments from a JavaScript file with a Ruby
script. I discovered that my regular expression matching seems to match
the biggest possible substring.
Wow, I only had to wait 20 minutes before posting (or you could have checked the regexp madness thread).
Seems today is greedy regexp day
V.-