kchoi kchoi - 1 year ago 96
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?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download