From: Josh Cheek Date: 2010-10-12T22:20:28+09:00 Subject: Re: Help with regexp's --001485f5b1ec665c3204926b5597 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Oct 12, 2010 at 8:11 AM, Thiago Massa wrote: > Is there any way to a regexp allow any character but the comma? > > My regexp is getting ugly like /(\x2E|\x3A|\x27|\x28|\x29|\x2D|\x21|\x2B)*/ > and so on(i ommited the real one for the love of god) > > I'm even thinking about implementing it myself like > > if not comma > pass > else > not_pass > end > > isn't there a way to extend the way ruby deals with regexp and make > something like "/everythingbutnotcomma" mean what i want? > > I'm sorry of my lack of knowledge about regexps... I'm trying to really > learn it once and for all. > > Thanks in advance. > > -- > Thiago Fernandes Massa > 11 83979414 > Use a negated character class /[^,]/ Here is an example http://www.rubular.com/r/6zUr2HVznL Everything that matches the regexp gets highlighted. In this case, every char matches, so it gets highlighted. Except the comma, because it does not match since the caret in the front of the character class says "match anything except" Here is more on character classes, if you are interested http://www.regular-expressions.info/charclass.html --001485f5b1ec665c3204926b5597--