re = /(,\d{3}$)/m
str = '1
00:00:06,000 --> 00:00:12,074
- = www.OpenSubtitles.org = -
2
00:01:35,623 --> 00:01:38,208
Apollo Três aqui.
Houston, você pode me copiar?
3
00:01:39,168 --> 00:01:41,378
Apollo Três, aqui é Houston.
Voce me ouve
4
00:01:41,503 --> 00:01:43,797
Bem recebido, de Houston.
Apollo Três aqui.
5
00:01:44,340 --> 00:01:48,385
Apollo Três, está tudo bem aqui.
6
00:01:49,428 --> 00:01:52,973
- Lee, você pode me copiar?
- Você é recebido, Capcom. Que falador.'
subst = '$1\\n<font color=#FFFF00>'
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