I assume you mean something like this (you really should've clarified, and for that I point you to
What makes a bad question? Before You Post ... How (Not) To Ask A Question How to ask questions the smart way )
#!/usr/bin/perl -w
use strict;
my $String = "Noo S pro NpppT Nop| NPP";
my $LongString = "YYY DDD $String RRR PPP";
my $Pattern1 = qr{N[^P]{2,4}[S|T]};
my $Pattern2 = qr{DDD\s};
for my $m ( $LongString =~ m{($Pattern1|$Pattern2)}g ) {
print "Yes! $m\n";
}
__END__
Yes! DDD
Yes! Noo S
Yes! NpppT
Yes! Nop|
Because you didn't format your question properly, I point you to
site how to and
(OBE) The Perl Monks FAQ
Because it's interesting, and potentially of use, I point you to Why I like functional programming by tilly.
I suggest you give a good gander to all of the links I provided you with (you might not get instant satisfaction, but you'll find 'em all useful, even if it takes a little while)
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.