Consider this (overly simplified) issue. I have a string,
that contains in it an optional "list" of foos. Each foo has
a recognizeable and distinct pattern, and of course there
are many different specific foos. I want to see if my
list of foos contains a certain specific foos. This problem
must be solved with a regex (for other reasons).
Example:
A foo is a one letter an one number. They are separated by
by one or more spaces. The list is preceded
by a list name and is separated from the list in the
"usual fashion".
Example input: bar a2 b2 c3 d3 d4 a1 f2 f3
I want the regex to be true if my list of foos contains d4
and b2.
$_ = /^\w+ # matches list name
(?:
\s+
[A-Za-z]\d
)*
$/x
will match a list of foos with it's label.
But, I need a way to match specific foos in any place in any
order insided the pattern.
Is this possible?
How?
Thanks.
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.