[clug] OT meta-regex question

David Gibson david at gibson.dropbear.id.au
Tue Feb 3 05:51:22 GMT 2004


On Tue, Feb 03, 2004 at 04:30:35PM +1100, Paul Bryan wrote:
> On Tue, Feb 03, 2004 at 02:43:39PM +1100, Paul Bryan wrote:
> > On Tue, Feb 03, 2004 at 02:24:22PM +1100, Gough, Chris wrote:
> > > For example:
> > >  A = '^.*$'
> > >  B = '^foo$'
> > 
> > C = '(A|B)'
> > 
> > or more clearly:
> > 
> > C = '(^.*$|^foo$)'
> > 
> > aPatternExists(C)
> 
> Sorry, that was complety brain-dead. It doens't even come close to your 
> question. I think it's time for a siesta.
> 
> Back to the question at hand. I think it would be possible to do what your
> talking about. Unfortunately, I don't know of a solution. So, grab the source
> for libregex and off we go. Does the thought of this make your brain feel
> any better? It doesn't help my brain any.
> 
> Seriously though, I think that's where you might have to look. What
> I'm thinking is, regex parsers normally walks through the regex and
> the string to be matched together (I think that's right from
> memory). 

Not quite - they will usually generate a finite state automaton (NFA
or DFA) from the regex, then execute the automaton with the string's
characters driving the state transitions.  Either the string will be
accepted or it won't.  The point is that it's always the string
driving the process, not the regex or it's automaton.

-- 
David Gibson			| For every complex problem there is a
david AT gibson.dropbear.id.au	| solution which is simple, neat and
				| wrong.
http://www.ozlabs.org/people/dgibson


More information about the linux mailing list