Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I, also, don't really understand the requirements | vaguely-stated requirements of the OP. The way I'd like to see a question like this posted (and a way that'd be more likely to get useful responses IMHO) is something like:

c:\@Work\Perl\monks>perl -wMstrict -le "use Test::More 'no_plan'; use Test::NoWarnings; ;; use constant TEST_ACCEPT => qw( {12} {1b} {a2} {ab} {12_34} {1b_34} {a2_34} {ab_34} {12_3d} {1b_c4} {a2_cd} {aa_bb_cc_dd_ee} {a1_11_1c_bb} {aaa} {a} ); ;; use constant TEST_REJECT => qw( {a_bb_cc_dd_ee} {aaa_bb_cc_dd_ee} {1_11_1c_bb} {123_11_1c_bb} {aa_} {a_} {_aa} {_a} {1} {123} {abc1} {_} ); ;; my $rx_scored = qr{ [[:alnum:]]{2} (?: _ [[:alnum:]]{2})* }xms; my $rx_alphas = qr{ [[:alpha:]]+ }xms; ;; my $rx = qr{ \A \{ (?: $rx_scored | $rx_alphas) \} \z }xms; ;; note 'all to be accepted'; ;; for my $string (TEST_ACCEPT) { ok $string =~ $rx, qq{accept '$string'}; } ;; note 'all to be rejected'; ;; for my $string (TEST_REJECT) { ok $string !~ $rx, qq{reject '$string'}; } ;; done_testing; " # all to be accepted ok 1 - accept '{12}' ok 2 - accept '{1b}' ok 3 - accept '{a2}' ok 4 - accept '{ab}' ok 5 - accept '{12_34}' ok 6 - accept '{1b_34}' ok 7 - accept '{a2_34}' ok 8 - accept '{ab_34}' ok 9 - accept '{12_3d}' ok 10 - accept '{1b_c4}' ok 11 - accept '{a2_cd}' ok 12 - accept '{aa_bb_cc_dd_ee}' ok 13 - accept '{a1_11_1c_bb}' ok 14 - accept '{aaa}' ok 15 - accept '{a}' # all to be rejected ok 16 - reject '{a_bb_cc_dd_ee}' ok 17 - reject '{aaa_bb_cc_dd_ee}' ok 18 - reject '{1_11_1c_bb}' ok 19 - reject '{123_11_1c_bb}' ok 20 - reject '{aa_}' ok 21 - reject '{a_}' ok 22 - reject '{_aa}' ok 23 - reject '{_a}' ok 24 - reject '{1}' ok 25 - reject '{123}' ok 26 - reject '{abc1}' ok 27 - reject '{_}' 1..27 ok 28 - no warnings 1..28
Of course, one would omit the test regex or use a dummy in an initial query post.


Give a man a fish:  <%-{-{-{-<


In reply to Re: Looking for a regular expression for the following pattern. by AnomalousMonk
in thread Looking for a regular expression for the following pattern. by skooma

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 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? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2022-08-07 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?