# Re: help with regular expressions

## torbenm@diku.dk (Torben Ęgidius Mogensen)12 Oct 2004 00:55:43 -0400

From comp.compilers

Related articles
help with regular expressions johndoe@yahoo.com (keith) (2004-10-09)
Re: help with regular expressions cdc@maxnet.co.nz (Carl Cerecke) (2004-10-12)
Re: help with regular expressions genew@mail.ocis.net (Gene Wirchenko) (2004-10-12)
Re: help with regular expressions jeremy.wright@microfocus.com (Jeremy Wright) (2004-10-12)
Re: help with regular expressions torbenm@diku.dk (2004-10-12)
| List of all articles for this month |

 From: torbenm@diku.dk (Torben Ęgidius Mogensen) Newsgroups: comp.compilers Date: 12 Oct 2004 00:55:43 -0400 Organization: Department of Computer Science, University of Copenhagen References: 04-10-077 Keywords: lex Posted-Date: 12 Oct 2004 00:55:43 EDT

keith <johndoe@yahoo.com> writes:

> write the regular expression for strings over the alphabet {a,b,c}
> that don't contain the contiguous substring baa. I've come up with
> this:
>
> (a|c|(ba(b|c))|bb|bc)*
>
> ??? Is this correct?

No, the strings "bbaa" and "babaa" are in the language you describe.

> binary numbers n such that there exists an integer solution of an+bn=cn,
> don't know what to do about this one :-( As far as I am concerned all
> binary numbers satisfy this condition as integer+*integer=integer.

The exercise says a^n+b^n=c^n, for which Fermats theorem says that
there exist integer solutions only when 0<=n<=2.

Torben

[I have an elegant regular expression that solves the problem, but
the margin of this message is too small to contain it.
-John]

Post a followup to this message