kchoi kchoi - 2 months ago 12
Ruby Question

Why is rubocop asking me to put // around regex when i'm using %r already?

I have the following regex

regexp = %r{

But when I run rubocop on it, it complains that I need to "Use // around regular expression."

How can I get around it?


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