From: Carlos Date: 2001-11-25T02:39:05+09:00 Subject: [ruby-talk:26351] regexp question Hi, I have problem figuring a regexp, I hope someone could help me. I must parse a simple configuration file, in whose syntax strings are delimited by single quotes ("''" represents a quote inside the string); and comments by `#' until the end of line. So, when I read each line, I want to strip off the comments. I figured out that I need to match a `#' after an even number (or zero) single quotes (to ensure I don't match a `#' inside a string). Example: config file line 'string' # this comment must strip off config file other line # this too 'this too' config file 'string ''# this must not match''' but #this yes Ok, how I make that? I tried /(?:'.*?')*#/ # match `#' after 0 or more quote pairs It works in the first two examples (#pre_match returns the line without the comment), but fails in the third. Anyone has any idea? Thanks.