in reply to A (non) reg-ex question
The long, "you can't," answer: A regexp, an achedemic regexp, won't work. I point that out since your example is a perl regular expression. I suggest looking up the pumping lemma and the basic tenants of a regular language. In short, what you need is something that requires stack memory. A real regular expression only needs memory for the input, the expression itself, and a pointer to say where weare at in the regexp. If the number of 0's and 1's have some sort of arithmetic relation, more likely than not, you can't. There are exceptions.
The long, "you can," answer: perl's regexp's are an extension of the regular expressions used for regular languages. The fact you have the /e flag totally completely blows it out of the water since oyu can freely allocate variables. Perl's regex's are a wonderful thing. Just stating the fact you can do context sensitive stuff in it.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: A (non) reg-ex question
by bart (Canon) on Mar 21, 2006 at 11:03 UTC | |
by exussum0 (Vicar) on Mar 21, 2006 at 16:06 UTC |