I’m writting a little program to convert some source files to html.
I’m using regexp’s to determine the content of each line and format it
accordingly. For example, if the line starts with a #, then it should be
output with a div (and id set to ‘comment’).
The problem is with matching the regular expressions. If I do this:
f = File.new(“myfile”, “r”)
line = f.gets
if line.match(/^# (.)/)
Then not only do I get the commen lines formatted properly, I also get a
“nil” for every other line in the file.
How should I be using regexps in conditionals? I’m sure this should be
but I’ve googled around for an hour and I can’t find what’s wrong.