ietf-openpgp
[Top] [All Lists]

[openpgp] Possible ambiguity in description of regular expressions: [^][]

2020-12-23 15:58:57
The description of regular expressions in Section 8 of 4880
(https://tools.ietf.org/html/rfc4880#section-8) says:

  A range is a sequence of characters enclosed in '[]'.  It normally
  matches any single character from the sequence.

Is an empty sequence allowed?  If so,

  []                  (1)

is a valid regular expression meaning *no match*.

  If the sequence begins with '^', it matches any single character not
  from the rest of the sequence.

Even if we assume that a sequence is non-empty, the rest of a one
character sequence after removing the first character is empty.  So,
it sounds like:

  [^]                 (2)

is definitely a valid regular expression meaning *match anything*.

  To include a literal ']' in the sequence, make it the first
  character (following a possible '^').

So, to match anything but a literal ']' we have to use:

  [^]]                (3)

And to match anything but '[' or ']' we have to use:

  [^][]               (4)

Wait... that can also be parsed as match anything (2) followed by
match nothing (1)!


Perhaps I'm misreading the standard.  I'd appreciate confirmation or
any help clarifying my mistake.

Thanks,

:) Neal

_______________________________________________
openpgp mailing list
openpgp(_at_)ietf(_dot_)org
https://www.ietf.org/mailman/listinfo/openpgp

<Prev in Thread] Current Thread [Next in Thread>