Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Regular Expression Help

by Basilides (Friar)
on Sep 05, 2002 at 16:16 UTC ( [id://195427]=note: print w/replies, xml ) Need Help??


in reply to Regular Expression Help

Do you want to match on parts of the string, eg just "Joe Fred," as well as combinations involving *all* the words? If so, here's a version which implements japhy's wicked combination routine from a query of mine here:
my $file = "xxxxxxxxx Joe xxxxxxx Fred xxxxxxxx Joe Fred Software xxxx +xxx Inc Software Fred Joe"; my $string = "Joe Fred Software Inc"; my @n = split / /, $string; my $max = 2**@n; for (my $i = 0; $i < $max; ++$i) { my ($bits, @used) = $i; while ($bits) { my $high_bit = int(log($bits)/log(2)); push @used, $n[$high_bit]; $bits &= ~(2**$high_bit); } my $match = join " ", @used; print "$match\n" if $file =~ m/$match/; }
Hope that's the kind of thing you wanted.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-25 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found