Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
<html>

Hmmm, Perl Mongers have always had a regex version of their name to take into account both Mongers and Mungers:

/Perl M[ou]ngers/ # char class version /Perl M(o|u)ngers/ # alternation version

Relatively easy to match the right people. But if we mix up Mongers, Mungers, and Monks all in one place we will have a less gracefull time of matching desirable PM variants. I mean, we'll most certainly want to match any of these:

Perl Mongers Perl Mungers Perl Monks

But this permissiveness certainly shouldn't extend to those who refer to themselves as:

Perl Munks Perl Mungs Perl Mongs Perl Monkers Perl Munkers

So the question is, what can we come up with that retains the simple elegance of /Perl M(o|u)ngers/ (or its character class equivelant) and ensures that we aren't matching one of the more hideous deviants?

Well, a couple of obvious attempts might be:

( /Perl M[ou]ngers/ || /Perl Monks/ ) /Perl (?:M[ou]ngers|Monks)/

Aaack! Just look at all those duplicated letters going to waste!

/Perl M(?:onk|[ou]nger)s/

Bletch, still pretty ugly -- and look, both the 'o' and the 'n' are still wastefully repeated on both sides of the alternation (as if we had an endless supply of ascii letters, sheesh!). This simply won't do. Therefore, in my humble opinion, our only option in this matter is to screw simplicity and elegance and go for the minimum alphabetical liability:

/Perl M(?:(o)|(u))n(?(2)(g)|(?:(g)|(k)))(?(5)|er)s/;

Much better, don't you think? And only one extra 'g' wasted. Now, before you start screaming about how this will deplete our supply of much needed parentheses, don't panic -- rumour has it, Larry Wall been secretly siphoning off parentheses from old Lisp programs for years! (sshhh).

.

(just(another(perl(wacko))))


In reply to Re: Re: Re: Re: Re: Re: New Gathering section? by danger
in thread New Gathering section? by KM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2024-04-23 07:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found