Erosia has asked for the wisdom of the Perl Monks concerning the following question:
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:The (^\w+) should match only strings that start with one or more alphanumeric character. Although it doesn't quite work as hoped.while (<FILE>) { />(.+) and (^\w+)</; print "$1 "};
I appreciate any help you experts may provide.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiple conditions
by ikegami (Patriarch) on Mar 13, 2010 at 21:35 UTC | |
by Erosia (Novice) on Mar 13, 2010 at 21:44 UTC | |
|
Re: Multiple conditions
by 7stud (Deacon) on Mar 14, 2010 at 08:15 UTC | |
by Erosia (Novice) on Mar 14, 2010 at 12:46 UTC | |
|
Re: Multiple conditions
by Anonymous Monk on Mar 13, 2010 at 21:35 UTC | |
|
Re: Multiple conditions
by Anonymous Monk on Mar 14, 2010 at 01:27 UTC |