Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Like this?
perl -E ' my $string = "xxxx yy zzzzz xxxx qqq xxxx yy zzzzz xxxx qqq"; my @array = $string =~ /\b(\w{2})\b.+?\b(\w{4})\b.+?\b(\w{3})\b/g; say "@array"; ' yy xxxx qqq yy xxxx qqq
Edit: here is an approach that lets you auto-customize the regex.
#!/usr/bin/env perl use strict; use warnings; use feature 'say'; my $regex = build_regex( 2, 4, 3 ); say "Regex: $regex"; my $string = "xxxx yy zzzzz xxxx qqq xxxx yy zzzzz xxxx qqq"; my @match = $string =~ /$regex/g; say "Match: @match"; sub build_regex { my ( $first, @others ) = @_; my $regex = qr{\b(\w{$first})\b}; $regex .= qr{.+?\b(\w{$_})\b} for @others; return $regex; } __END__ Regex: (?^:\b(\w{2})\b)(?^:.+?\b(\w{4})\b)(?^:.+?\b(\w{3})\b) Match: yy xxxx qqq yy xxxx qqq

In reply to Re: match sequences of words based on number of characters by frozenwithjoy
in thread match sequences of words based on number of characters by nicemank

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [LanX]: oh there is even an Elsassian version ... =)
    [Eily]: I don't think there's any link between the name and the character in the french version
    [Eily]: Elsassian? Is that the language of Elsa?
    [LanX]: Obelix?
    Eily runs to safety
    [LanX]: https://en. wiki/Elsassian
    [Eily]: LanX Assurantourix
    [karlgoethebier]: Lanx: nit picking: isn't it "les petits-bourgeois"?
    Eily learned about Elsass
    LanX doesnt care about orthografix

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (14)
    As of 2017-05-24 15:27 GMT
    Find Nodes?
      Voting Booth?