A regex pattern defines a set of strings. In theory, it would be possible to generate the set of strings a regex pattern defines, achieving what you want. There's no means to do that in core Perl, but there might a module to do this.

Update: No, there's really simple pattern that define a set containing just the desired string. I was thinking of something like qr/^(?:cat\nman\n){$n}\z/, but that's not correct.

I'm not sure if it exists as a module because it's not really a solution to any problem. Regex weren't designed to compose strings. With that in mind, I'll leave you with the following two alternatives:

Silly regex-based solution:

join "", map s/\z/ cat\nman\n/r, 1..$n

But that's just an expensive version of

join "", map "$_ cat\nman\n", 1..$n

In reply to Re: Can I get some help with a regex please by ikegami
in thread Can I get some help with a regex please by misterperl

Title:
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, details, 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, summary, 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.