Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Perl will not match my RegEx pattern....

by FierceMoose (Initiate)
on Mar 19, 2014 at 14:18 UTC ( [id://1078942]=note: print w/replies, xml ) Need Help??


in reply to Perl will not match my RegEx pattern....

Thanks to everyone for your help.

Below are examples of the output requested. I'm refraining from giving entire list search returns 4375 entries, which is the expected amount, all are being seen as invalid due to some error in my code. I've tried chomp on the returned data, but no change in results, chop just removed last char and invalidated the results.

Found Invalid Cube Number: A1.01A Found Invalid Cube Number: A1.01B Found Invalid Cube Number: A1.01B ... Found Invalid Cube Number: A2.06AA Found Invalid Cube Number: A2.06AABB Found Invalid Cube Number: A2.06B ... Found Invalid Cube Number: H2.25 Found Invalid Cube Number: H3.10 Found Invalid Cube Number: Imaging Center Found Invalid Cube Number: Italy Found Invalid Cube Number: K1.03A Found Invalid Cube Number: K1.03B ... Found Invalid Cube Number: R1.19G Found Invalid Cube Number: R2.25AA Found Invalid Cube Number: R2.25AABB Found Invalid Cube Number: R2.25BB Found Invalid Cube Number: R2.25D Found Invalid Cube Number: R2.25DD Found Invalid Cube Number: R2.25F Found Invalid Cube Number: R2.25FF ... Found Invalid Cube Number: V3.26P Found Invalid Cube Number: V3.26Q Found Invalid Cube Number: V3.26QR Found Invalid Cube Number: V3.26R Found Invalid Cube Number: V3.26R Found Invalid Cube Number: V3.26S Found Invalid Cube Number: V3.26ST Found Invalid Cube Number: V3.26T

In the results above, all should be a valid Seat Location (pattern) except for 'Imaging Center' & 'Italy'.

FWIW- below is the actual search performed using Net::LDAP. This format has been used in many other scripts besides this one, but thought it may give context to what's happening.

my $userFilter = "(SeatLocation=*)"; my &userAttributes = [ 'SeatLocation', 'uid' ]; my $searchMesg = $ldap->search (base => $userBase, filter => $userFilt +er, scope => $scope, attrs => $userAttributes); my @entries = $searchMesg->entries; my $totalFound=@entries; # determine the number of entries found

Thanks again!

Replies are listed 'Best First'.
Re^2: Perl will not match my RegEx pattern....
by hazylife (Monk) on Mar 19, 2014 at 14:44 UTC
    $ perl -nle 'print "$_ is ", /^[A-Z][1-9]\.\d\d?[A-Z]*$/ ? "valid" : " +invalid"' 1078942.in A1.01A is valid A1.01B is valid A1.01B is valid A2.06AA is valid A2.06AABB is valid A2.06B is valid H2.25 is valid H3.10 is valid Imaging Center is invalid Italy is invalid K1.03A is valid K1.03B is valid R1.19G is valid R2.25AA is valid R2.25AABB is valid R2.25BB is valid R2.25D is valid R2.25DD is valid R2.25F is valid R2.25FF is valid V3.26P is valid V3.26Q is valid V3.26QR is valid V3.26R is valid V3.26R is valid V3.26S is valid V3.26ST is valid V3.26T is valid
    EDIT: to weed out .0 and .00, use this pattern instead: /^[A-Z][1-9]\.(?:[1-9]\d?|0[1-9])[A-Z]*$/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1078942]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-04-24 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found