Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Why machine-generated solutions will never cease to amaze me

by bart (Canon)
on Nov 10, 2004 at 16:05 UTC ( [id://406701]=note: print w/replies, xml ) Need Help??


in reply to Why machine-generated solutions will never cease to amaze me

Just for the record, I'd like to point out that there's the module Regex::PreSuf (short for prefix+suffix), which does something similar — namely, combining strings into a single pattern that matches them all:
#! /usr/local/bin/perl -wl use Regex::PreSuf; print presuf(qw(sad salad spread));
It produces:
s(?:al|pre)?ad
Heh. I think you might feel right at home with it. :)

Replies are listed 'Best First'.
Re^2: Why machine-generated solutions will never cease to amaze me
by grinder (Bishop) on Nov 10, 2004 at 16:54 UTC

    Yes, I know about that module. Its biggest shortcoming is that it works on single characters, which makes it pretty useless for applying it to patterns that contain meta-characters.

    For instance, the two patterns foo\d+bar and foo\s+1 will produce foo\\(?:d\+bar|s\+1), and that's not going to match anything the individual patterns match.

    - another intruder with the mooring of the heat of the Perl

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found