Just an idea
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11156323 use warnings; my %data = map { (split)[1], $_ } <DATA>; for my $searchfor ( qw( 940 ABFD-1 ABFD1 D7RD DD482 ) ) { print "\n$searchfor\n"; print ' ' x 8, $data{$_} for grep match($searchfor, $_), sort keys +%data; } sub match { my ($match, $to) = map tr/-//dr, @_; $to =~ /\*/ or return $to =~ $match; my @pattern = map s/\*/[A-Z0-9]/gr, $to =~ /(?=(.{@{[length $match]} +}))/g; local $" = '|'; return $match =~ /@pattern/; } __DATA__ 1 ABFD-1234 AAA 2 ABFD-178G BBB 3 F2HB-9401 AAA 4 ZDDR-00W5 DDD 5 D7*D-48*6 EEE
Outputs:
940 3 F2HB-9401 AAA ABFD-1 1 ABFD-1234 AAA 2 ABFD-178G BBB ABFD1 1 ABFD-1234 AAA 2 ABFD-178G BBB D7RD 5 D7*D-48*6 EEE DD482 5 D7*D-48*6 EEE
In reply to Re: Partial Searches Against Multiple Wildcards
by tybalt89
in thread Partial Searches Against Multiple Wildcards
by p_jacobson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |