in reply to Re: Why would one want in a regex a class with only a single entry?
in thread Why would one want in a regex a class with only a single entry?

If a negated class can qualify as a single character class, then so should the POSIX ones ([::]), property ones (\p{}), "normal" Perl backslash ones (\d, \s, etc.), among others.

Replies are listed 'Best First'.
Re^3: Why would one want in a regex a class with only a single entry?
by davido (Cardinal) on Mar 25, 2008 at 06:39 UTC

    That doesn't bother me. The OP seemed to be discussing the validity and practicality of single-entry character classes. And I believe he was discussing them in the context of the [....] operator in a regexp. The backslash CC's and property CC's are already 'single entry', so probably not really so relevant to the discussion, particularly where they can stand-alone outside of a user-defined character class.

    Certainly the POSIX classes constitute "single entries". And that's definitely another good argument for why single-entry character classes are practical, and should be legal (which, of course, they are).

    The negated character class of a single entry just happened to be the first example that jumped to my mind. Your POSIX thought is great too.


    Dave

      Thanks for your response, as I was trying to clarify, to self, just what makes a "single entry class". I was thinking strictly of a character class without any meta characters.

      davido and pary, thanks. davido you're correct...I was checking not so much on the validity of a single entry class (I know it's legal). I was just curious about why a programmer might want to have a single character class. pary made me think and realize, much like you're note of the negated class, that there are meta-character situations where a single entry could be usefule, too.

      Thanks to you both. I appreciate your insights.

      ack Albuquerque, NM