in reply to Re: regular expression-xerox
in thread regular expression-xerox

Not quite. You haven't considered:
  1. Characters that have a special meaning, like -, ^, and ] (and that meaning is position dependent!)
  2. Characters that inside a character class don't have a special meaning, but have one outside the class, like +, ?, * and others.
  3. POSIX character class syntax.

Abigail

Replies are listed 'Best First'.
Re: Re: regular expression-xerox
by kvale (Monsignor) on May 03, 2004 at 21:42 UTC
    My solution is correctly answers the particular requirement the OP stated: convert the character class 'ABCD' to a form that uses alternation. If one extrapolates that requirement to all alphanumerics, them my type of solution still works.

    If one exptrapolates to metacharacters like those in 1. and 2., or to predefined POSIX classes or Unicode characters, as in 3., then obviously the parser and translator must be extended to handle these situations.

    But for the simple requirements stated by the OP, a simple solution is best.

    -Mark