Help with regexp's

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.

On Tue, Oct 12, 2010 at 3:11 PM, Thiago M. [email protected]
wrote:

Is there any way to a regexp allow any character but the comma?

Use a negated character class [^,] or use negated matching !~.

isn’t there a way to extend the way ruby deals with regexp and make
something like “/everythingbutnotcomma” mean what i want?

What exactly are you trying to achieve with matching? Do you want to
make sure there is no comma in a sequence or do you want to do
substitutions?

I’m sorry of my lack of knowledge about regexps… I’m trying to really
learn it once and for all.

I highly recommend “Mastering Regular Expressions”.

Kind regards

robert

On Tue, Oct 12, 2010 at 8:11 AM, Thiago M. [email protected]
wrote:

not_pass

Thiago Fernandes Massa
11 83979414

Use a negated character class /[^,]/

Here is an example Rubular: [^,]

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