Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby/Regex Error: warning: character class has duplicated range

Tags:

regex

ruby

Im trying to get this Ruby code beautifier working and have hit on a problem to do with regular expressions that to be honest I just don't understand as my experience with them is extremely limited.

The error that Im getting is:

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

Which points to this line:

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

Could someone please be kind enough to point out what the issue is with this expression?

Thanks.

like image 308
Andrew Avatar asked Jan 13 '12 11:01

Andrew


1 Answers

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

This discussion might help understanding it more.

like image 148
trueunlessfalse Avatar answered Oct 03 '22 21:10

trueunlessfalse