From: Jose Calderon-Celis Date: 2011-05-02T00:42:45+09:00 Subject: Re: Formatting a long regex: can a character class [] be split over lines? --20cf300fae397a4f9b04a238bb25 Content-Type: text/plain; charset=ISO-8859-1 http://es.w3support.net/index.php?db=so&id=150095 --- Jose Calderon-Celis 2011/5/1 Alexey Muranov > Hello, > i am wandering if it is possible to split a character class ([...]) in > Ruby regex over multiple lines. > > I know that the /x option allows to ignore whitespace, so i can write : > > email_format = /\A( > [A-Za-z\d\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+ > \.)* > [A-Za-z\d\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]+ > @([a-z\d\-]+\.)+[a-z\d\-]+\z/x > > However, if i try to split inside a character class: > > name_format = /\A[A-Za-z\d > \!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~]\z/x > > i get the warning: > > warning: character class has duplicated range > > (apparently it is about the space character being included multiple > times inside []). > I want the space and newlines to be disregarded inside [] to format it > over multiple lines, is this possible? > > Thanks, > > Alexey. > > -- > Posted via http://www.ruby-forum.com/. > > --20cf300fae397a4f9b04a238bb25--