Regex multiline weirdness

(Nikolai Weibull) #1

Derek Wyatt wrote:

~ str.sub(/<[^>]*?$/m, "")

The thing is that $ matches an end-of-line, so the non-greedy * stops
cold right before the first newline. You can use \Z to matche the
end-of-string instead, but I don't think that this regular expression is
going to do what you want anyway. Why are you using non-greedy matching
if you want it to go on to the end of the string?,


Nikolai Weibull: now available free of charge at!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.