From: RichardOnRails Date: 2009-11-13T08:00:11+09:00 Subject: DRYing a Regex I've got a routine that works fine at building an array of upper-case strings extracted from a string: aNewList = [] s = StringScanner.new sNewList upper = /[A-Z]+/ not_upper= Regexp.new( upper.source.sub( /\[/, '[^' ) ) while not s.eos? case when s.skip(upper); aNewList << s.matched else s.skip(not_upper) end end But the not_upper Regexp definition is really a kludge. It somewhat camouflages what is really /[^A-Z]+/ I'd like to DRY it by expressing it as something like !upper. I need something like !~ we use normally with string searches. Any ideas? -- Richard