Ruby

Ruby

Made by DeepSource

gsub(/\Aprefix/, '') can be replaced by delete_prefix('prefix') RB-PR1026

Performance
Major
Autofix

The delete_prefix('prefix') method is faster than gsub(/\Aprefix/, '').

Bad practice

str.gsub(/\Aprefix/, '')
str.gsub!(/\Aprefix/, '')
str.gsub(/^prefix/, '')
str.gsub!(/^prefix/, '')

Recommended

str.delete_prefix('prefix')
str.delete_prefix!('prefix')