vctr
vctr

Reputation: 315

Regular expression escape warning

For code

url.gsub(/"|\[|]| /, '')

ruby raises warning

warning: regular expression has ']' without escape: /"|\[|]| /

How to fix it?

Upvotes: 1

Views: 213

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174706

Your regex would be reduced to,

url.gsub(/[ "\[\]]/, '')

Upvotes: 1

Related Questions