I wonder why none of the people responded to this post actually
read the post carefully. They all come up with solutions that
use two regexes. What's so hard to understand about:
I'm actually reading the pattern from a
configuration file. Everything outside of the slashes is not changeable.
You have a misunderstanding about the meaning of
[ ] inside a regular expression.
[ ] is a character class, and matches exactly
one character. Inside you either list the characters that
are allowed to match, or the characters that aren't allowed
to match. [^(H\-000)(IF\-000)] means the same
as [^(H\-0)IF] and means "match a single character,
the character could be anything, except a (, an H, a dash,
a 0, a ), an I or an F.
If I understand your requirements, you are looking for all
files that start with PH, and do not end with either "H-000" or
"I-000". The following regex ought to work:
/^PH(?:.{0,4}|.*(?![HI]-000).{5})$/
It works with 5.004_02.
Abigail
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.