Just for the record, that's ill-formed html in your example:
<B><P ALIGN=CENTER>My Text I want to grab 1</B></FONT><p>
most of the issues will be ignored by most browsers, but are you certain? If displayed !eq actual, regex will have a hard time
(and, OT: writing 4.01 compliant code and using css IS worth the trouble -- for anything you're putting online, anyway)
Directly on your question: Note that your pattern is greedy, (.+), aka one-or-more-of-anything_except_a_newline. As written, $line =~ m/<B><P ALIGN\=CENTER>(.+)<\/B><\/FONT>/g; that should swallow everything UP TO the last end_bold_new_para tags.
And re capturing all instances: suggest you push to an array inside a foreach loop. The array subscript will be incremented for each new item found.
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.