I’m trying to get this to work:
data = "Testing: Download complete (This is a string) - Priority 0 Some random value Testing: Download complete (This to) - Priority 0 Another random value"
puts $1 if data =~ /Testing: Download complete \((.*?)\) - Priority.*?$/i
I want to print This to, right now This is a string is being printed.
The idea is to get the value as far as to the right as possible.
Use
The initial
.*will match until the end of the line, and the rest of the regex will backtrack as much as needed to match. Therefore, the last possible match will be found.