impalanator has asked for the wisdom of the Perl Monks concerning the following question:

We have an application that only allows one line of regex to remove generic accounts from the application and license count. I can't figure out the syntax for the logic. The normal accounts begin with X, Y, or Z and are followed by 8 characters. I use the code below often to find normal accounts. /\b[XYZ]\d{8}\b/ But the application wants regex input to strip out the generic accounts. I tried /^[^XYZ]/ works, but still pulls generic accounts that begin with X, Y , or Z. Any ideas on how to return data that does not start with X, Y, or Z followed by 8 digits? Thanks much, Ed

Replies are listed 'Best First'.
Re: Regex to remove generic accounts
by ikegami (Patriarch) on Oct 27, 2008 at 23:41 UTC
Re: Regex to remove generic accounts
by JavaFan (Canon) on Oct 27, 2008 at 23:42 UTC
    I'm not sure I fully understand what you want, but it may be that
    /^(?![XYZ][0-9]{8})/
    will do what you want.

      Is there any reason that you used [0-9] rather than \d?

      I'm so adjective, I verb nouns!

      chomp; # nom nom nom

        That did the trick, thanks Monks!
        I will have to look up this ?! code. Is that part of atomic grouping?
        I prefer to use \d instead of [0-9] because it's less typing and special characters :). They are equivalent right?

        Thanks again,
        Ed