str = "Error: heroku 6.14.38 is already installed
To upgrade to 7.7.1, run `brew upgrade heroku`"
r = /
\d{1,2} # match one or two digits
\. # match decimal
\d{1,2} # match two digits
\. # match decimal
\d{1,2} # match two digits
.+? # match any number of characters, lazily
\K # discard match so far
\d{1,2} # match one or two digits
\. # match decimal
\d{1,2} # match two digits
\. # match decimal
\d{1,2} # match two digits
/xm # free-spacing regex definition and multiline modes
str[r]
#=> "7.7.1"