in reply to Simple Regex for Alpha string

/^[A-Z]{2}$/ is about as concise and explicit as you can get for your purposes; probably the only thing that might cause problems are higher order ASCII characters (like accented ones, or Unicode encodings), but for the straight-foward 7-bit character set, you've got it nailed.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: Re: Simple Regex for Alpha string
by jlongino (Parson) on Nov 14, 2001 at 01:05 UTC
    Thanks Masem. I don't expect to encounter HO ASCII but then you never know. How would one handle that situation? If this requires a too lengthy reply feel free to direct me to an appropriate doc or whatever. Maybe Japhy references something like this in his soon-to-be book?

    --Jim

      For handling non-ASCII characters you can do a use locale; (see perllocale) and use the POSIX character class "upper": /^[[:upper:]]{2}$/
        I was going to say the same thing about using a POSIX class, but aside from the perllocale issue. I think generally its better to use them when you can.

        Yves / DeMerphq
        --
        Have you registered your Name Space?