Greetings All.

I'm seeking the greater wisdom of PerlMonks on patter matching issue that's been plaguing me. It's probably something obvious, but I appear to be blind to it. Running a simple script that query's LDAP, via Net::LDAP, and have it report back Seat data that does not follow the expected pattern, easier explained by Test Cases below. Here's the snippet of code used for processing data retrieved from LDAP:

for($c=0; $c < $totalFound; $c++) { my $SeatLoc = $entries[$c]->get_value('SeatLocation'); if ($SeatLoc =~ /(\b[A-Z]{1}\d{1}\.\d+[A-Z]*)/) { print "Valid Seat Found: $SeatLoc.\n"; } else { print "Found Invalid Seat: $SeatLoc\n"; } }

Believe I've got the correct RegEx for the pattern match, tested on 'My Regex Tester' but cannot seem to get it to work in Perl, doesn't match on a single one.

Test Cases:

  • A1.23BC - Correct
  • U2.60L - Correct
  • R2.32 - Correct
  • C1.3L - Correct
  • AB3.45E - Invalid
  • D45.1A - Invalid
  • Some Bldg - Invalid
  • Please help me find my way back to the right path.

    Thanks!


    In reply to Perl will not match my RegEx pattern.... by FierceMoose

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.