which removes the “^”, but I need to remove the “^L” when they are
together and at the beginning of the sentence.
irb(main):001:0> ts = “^LThe beginning of the sentence”
=> “^LThe beginning of the sentence”
irb(main):002:0> ts.sub /^^L/, ‘’
=> “The beginning of the sentence”
Also:
Do you really mean ^ (start of line) or do you mean \A (start of
string)?
No need to use gsub if there’s only ever going to be a single
match.
Yours doesn’t work because characters in the square brackets can’t be
escaped. Instead of matching that character, it will match “”, “^”,
or “L”. Phrogz has the right answer; just thought I’d explain why his
works and yours doesn’t.