From: Martin Weber Date: 2004-01-11T06:05:52+09:00 Subject: Re: regex to NOT match? On Sun, Jan 11, 2004 at 05:57:17AM +0900, Ruby Baby wrote: > Sorry it seems like the smallest thing, but I'm stuck on this. > > I'm trying to make a simple regex to strip away characters that are NOT certain characters I name. > I'm unclear on what Ruby uses as a "NOT" match in regex, like ! is for != > (Or if it uses the ^, where does it put it?) > > EXAMPLE: > > myString = 'I want only the letters a and t and period. When done it should look like atttaatta.tatttaatta..' > > # this doesn't work of course: > puts myString.gsub(!/at\./, '') puts myString.gsub(/[^at.]/, '') -Martin