Ruby / Regex error: warning: character class has duplicate range

I am trying to get this Ruby code beautifier , working and got into the problem with regular expressions, and, frankly, since my experience with them is extremely limited.

Error received by Im:

warning: character class has duplicated range: /.*=\s*<<-?\s*([_|\w]+).*/ 

Which points to this line:

 here_doc_term = tline.sub(%r{.*=\s*<<-?\s*([_|\w]+).*},"\\1") 

Can anyone be kind enough to indicate that the problem is with this expression?

Thanks.

+7
source share
1 answer

Basically this warning tells you that the character class you are using has some redundant pattern. I assume it points to [_|\w] , since \w already contains underscores.

This discussion may help in understanding this.

+8
source

All Articles