Poor man's answer:
it is possible indeed, and the demonstration is quite
simple:
- Given the maximum length of the string, generate
every possible string and match against the regexp. It's obviously
a finite number, possibly huge but finite.
- If the string matches, push it into an array which is initially
empty. A number less than a finite number (or equal) is certainly finite.
Now this is purely theoretical and ridiculously inefficient, but it can be done quite easily as a proof of concept if you like.
Be careful when you generate the possible strings (if you're really going to), Unicode is out there!
Another much more reasonable approach would be studying the Perl code that
generates the Finite State Machine used to match a certain
regexp and use that as a starting point for generating
strings instead of matching them. It wouldn't probably
be too bad if backtracking and other fancy features weren't there.
-- TMTOWTDI
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.