in reply to regex that simulates boolean logic
It's a little hard to see quite how you can use a regex any place that you can't use "conventional boolean logic".
However, one way to have a single regex that can be used to reject or fail a given list of numbers would be to make the regex match the specified list and then negate the test by either using !~ or simply ...not m//....
You can avoid it matching smaller chunks of larger numbers (ie. finding 7000 as a part of 70000) by anchoring the expression at both ends. Which anchor is appropriate depends on how and where it would be used. This might work for you.
@tests =qw/1 2 3 7 700 70000 7000 7777 7778 3886200 2200 8488 3406 91 +00 29389988 7688 5000 20 3408 3404 7648/ $fail = qr/\b(?:7000|7777|7778|3886200|2200|8488|3406|9100|29389988|76 +88|5000|20|3408|3404|7648)\b/ perl> for (@tests) { print /$fail/ ? "$_ failed\n" : "$_ passed\n" } 1 passed 2 passed 3 passed 7 passed 700 passed 70000 passed 7000 failed 7777 failed 7778 failed 3886200 failed 2200 failed 8488 failed 3406 failed 9100 failed 29389988 failed 7688 failed 5000 failed 20 failed 3408 failed 3404 failed 7648 failed
Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.
|
|---|