Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fixed Regexp warning: character class has duplicated range #252

Merged
merged 1 commit into from Jan 13, 2012

Conversation

Projects
None yet
3 participants
Contributor

pda commented May 29, 2011

Removed redundant \d from regex character class that already has \w, to prevent the following warning in ruby 1.9.2p180:

mail/lib/mail/fields/common/parameter_hash.rb:32:
  warning: character class has duplicated range: /([\w\d\-]+)'(\w\w)'(.*)/
Removed redundant \d from regex character class that already has \w.
This was causing the following warning during Rails test suite:

gems/ruby-1.9.2-p180/gems/mail-2.3.0/lib/mail/fields/common/parameter_hash.rb:32: warning: character class has duplicated range: /([\w\d\-]+)'(\w\w)'(.*)/
Contributor

pda commented Jun 14, 2011

Two bytes to fix hundreds of warnings throughout mail and rails.. what do you say? :)

This warning shows up on Ruby 1.9.3 as well.

For those of you that can't read regex and don't see why \d is redundant, \w is [a-zA-Z0-9_], or all letters (uppercase and lowercase), as well as any digit and the underscore. \d is any digit. So \w\d would be expanded to [a-zA-Z0-9_0-9].

Please merge this in.

Contributor

pda commented Nov 5, 2011

Thanks Henrik - I should have been clearer about the regular expression.

It'd be great to see this fix merged in.

I see #248 fixes this too, as well as some other warnings in the test suite.

mikel added a commit that referenced this pull request Jan 13, 2012

Merge pull request #252 from pda/fix-regex-character-class-warning
Fixed Regexp warning: character class has duplicated range

@mikel mikel merged commit 7afba28 into mikel:master Jan 13, 2012

Owner

mikel commented Jan 13, 2012

Thanks :) Good find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment