re = /^([A-Z])(?=.*\r?\n-)/m
str = '167
00:06:59,794 --> 00:07:01,379
Well, I would like to see
your face as soon as possible.
168
00:07:01,421 --> 00:07:03,048
Really?
- If that\'s possible, yeah.
169
00:07:03,089 --> 00:07:04,007
- Really?
- Mm-hmm.
170
00:07:04,049 --> 00:07:05,550
I wanna see your face.
- Okay.
171
00:07:05,592 --> 00:07:07,427
Let\'s just order so we can get
the business out of the way,'
subst = '- $1'
result = str.gsub(re, subst)
# Print the result of the substitution
puts result
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html