I have the following regex
regexp = %r{
((returned|undelivered)\smail|mail\sdelivery(\sfailed)?)
}x
But when I run rubocop on it, it complains that I need to "Use // around regular expression."
How can I get around it?
You can disable (and enable) any rubocop cop by adding a .rubocop.yml
file to the root of your project folder and setting up the appropriate configurations. To see what you can do, check out the global default.yml
in your rubocop package. It's fully commented.
For this particular problem, create a .rubocop.yml
and...
To disable the cop completely:
Style/RegexpLiteral:
Enabled: false
To always use %r
:
Style/RegexpLiteral:
EnforcedStyle: percent_r
I don't run rubocop so not sure this will solve your problem. You can use // instead of {} to surround the regex when using %r:
regexp = %r/((returned|undelivered)\smail|mail\sdelivery(\sfailed)?)/x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With