Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DRYing a Regex

0 views
Skip to first unread message

RichardOnRails

unread,
Nov 12, 2009, 4:47:44 PM11/12/09
to
Hi,

I got a routine that works fine at building an array of upper-case
string extracting from a string:

while not s.eos?
if s.skip(/[A-Z]+/)
aNewList << s.matched
else
s.skip(/[^A-Z]+/)
end
end

I'd like to say something like the following. But !r doesn't work.
Can a Regex be negated somehow?

r = /[A-Z]+/
while not s.eos?
if s.skip(r)
aNewList << s.matched
else
s.skip(!r) # Doesn't work, of course. What does?
end
end

Thanks in advance,
Richard

Ian Collins

unread,
Nov 12, 2009, 4:54:01 PM11/12/09
to
RichardOnRails wrote:
> Hi,
>
> I got a routine that works fine at building an array of upper-case
> string extracting from a string:
>
> while not s.eos?

Try a group for the language you are using!

--
Ian Collins

RichardOnRails

unread,
Nov 12, 2009, 5:00:03 PM11/12/09
to

Thanks Ian. I posted too fast :-(

0 new messages