Hello wise men.

I am struggling with regular expressions. I know the fundamentals, but when I want to add two conditions within one "/.../", I have no idea how to do that.

What I want is for the program to print only what is between ">" and "<" at each line, but only if there isn't another > or < within the original ones. For instance: >knowledge< is good and >knowled<ge< is bad. My while-loop looks like this:
while (<FILE>) { />(.+) and (^\w+)</; print "$1 "};
The (^\w+) should match only strings that start with one or more alphanumeric character. Although it doesn't quite work as hoped.

I appreciate any help you experts may provide.


In reply to Multiple conditions by Erosia

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.