{
has special meaning in regular expression.
PATTERN{m,n}
Above matches PATTERN repeated m~n times.
If you want avoid that warning (to match literally match {
) escape it.
txt.gsub! /^.*\{/, '{'
UPDATE
BTW, /^.*{/
does not catch the first {
because .*
is greedy match; It consume as much as possible.