ruby - Match as to the right as possible using =~ (regex) -
i'm trying work:
data = "testing: download complete (this string) - priority 0 random value testing: download complete (this to) - priority 0 random value" puts $1 if data =~ /testing: download complete \((.*?)\) - priority.*?$/i
i want print this to
, right this string
being printed.
the idea value far right possible.
use
puts $1 if data =~ /.*testing: download complete \((.*?)\) - priority/i
the initial .*
match until end of line, , rest of regex backtrack as needed match. therefore, last possible match found.
Comments
Post a Comment