From: William Djaja Tjokroaminata Date: 2002-09-25T02:21:15+09:00 Subject: Re: Regular expression object question Hi, Well, if your regular expression is not very complicated, you can simply use the Regexp "new()" and "source()" methods: re = Regexp.new ('xyz') re = Regexp.new (re.source + 'abc') .... Regards, Bill ========================================================================== Daniel Berger wrote: > Hi all, > Is there a way to add a new regex to an existing regular expression > object? > In other words, say I start with a pattern I want to match: > re = /xyz/ > But later, I decide that I want to also match "abc". As it stands now, > I have to create a new regex object for that. Thus: > re2 = /abc/ > This could go on indefinitely, so simply doing this could quickly become > cumbersome: > if re.match(string) || re2.match(string)... > Thus, what I would like is a way to "push" a new regex onto an old one > (i.e. add an "and" or "or"). > example: > re = /xyz/ > re.push("|abc") -> re is now /xyz|abc/ > Thoughts? Should I just create my own subclass that does this and shut > up? > Regards, > Dan