As others have already stated, you've posted insufficient information for us to provide a solution.
It sounds like you probably want code like this:
for my $line (@lines) {
next if $line =~ /\d/;
print $line if $line =~ $regex_that_is_working;
}
The regex you posted (with the vague "it's not working") has a lot of potential problems:
-
You have a boundary assertion (\b) in one place and two plain 'b' letters elsewhere:
are they also meant to be assertions?
-
You have one alternation (with |) and later an escaped pipe ('\|'):
was that supposed to be another alternation?
-
You're using a capture but don't access what is captured.
What's the intent here?
-
You have '0-9' which I suspect should be '[0-9]';
I'm even wondering if '!0-9' should be '[^0-9]'.
-
You have what appears to be anchor assertions ('^' and '$') in strange positions;
there is no 'm' modifier to indicate a multiline string.
-
There are other bits I just gave up trying to guess at.
Take a look "perlintro: Regular expressions".
This has introductory information on that page;
it also has many links to more detailed documentation on other pages.
In addition, search for /regular expression/
on the main "perldoc - perl" page.
The "How do I post a question effectively?" page, on this site, will give you an idea of what you need to post to get better answers from us.
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.