Regexp warning

I’ve upgraded to ruby2.1.0 and tried it on my program and I got a
warning:

IFMapper/IFMReader.rb:102: warning: character class has duplicated
range: /^\s*[\w_-.]+\s*=.*$/

It seems ruby2.1.0 is understanding the - sign as a range instead of
using the backslash to treat the - as a minus sign only.

On Jan 20, 2014, at 7:18 PM, Gonzalo G. [email protected]
wrote:

I’ve upgraded to ruby2.1.0 and tried it on my program and I got a
warning:

IFMapper/IFMReader.rb:102: warning: character class has duplicated
range: /^\s*[\w_-.]+\s*=.*$/

It seems ruby2.1.0 is understanding the - sign as a range instead of
using the backslash to treat the - as a minus sign only.

Not seeing a warning with that expression on 2.1.0. What is the context
of that code?

Anyway, if you are indeed seeing a warning, I dont think that its caused
by the - (minus). The \w includes the _ (underscore), so if youre
getting a duplication warning it is most probably caused by that.

FYI, you can place the - (minus) at the beginning or the end of the set
(without escaping it). It will not be treated as part of a range in
those cases.

Regards,
Ammar