Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

regexp easy one (I think)

Posted on 2000-03-09
4
Medium Priority
?
202 Views
Last Modified: 2010-03-05
This line sets the variable buffer to everything in between the "</HEAD>" tag and the </BODY> tag in a file.  

$buffer =~ m/<\/HEAD>(.*)<\/BODY>/is;

I have a problem in that some of my documents don't have </BODY> tags and some do... I need the line to do this (here is the english)

$buffer is equal to all text in between the </HEAD> tag and either the </BODY> tag, if there is one OR this string: /commonfooter.cgi

help?
0
Comment
Question by:georgia
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 200 total points
ID: 2603064
The | symbol gives you  alternation (OR) in regular expressions.
$buffer =~ m/<\/HEAD>(.*)(<\/BODY>|\/commonfooter.cgi)/is;
print($1);
0
 
LVL 5

Expert Comment

by:PC_User321
ID: 2603143
teraplane, you should escape the literal '.'
0
 

Author Comment

by:georgia
ID: 2603146
Thanks a bunch!
0
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 2603171
well spotted PC,
$buffer =~ m/<\/HEAD>(.*)(<\/BODY>|\/commonfooter\.cgi)/is;
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question