reg ex search for companies

Posted on 2006-04-11
Last Modified: 2010-03-05
I have a large html file that I am trying to scrape the names of companies out of. The company names are always in the following format:

<a href="offsite_quotes.asp?content=">Some Place, Inc.</a>

I would want "Some Place, Inc." as the result here. The company names could be one or more words, they might even have special characters in the name. (@, -, etc) But they will always have "<a href="offsite_quotes.asp?content=" followed by a url and a "">", then the name of the company.

There might be more than one company name per line. If there is, it would be important to print each one per line. I don't know if doing this with a open file, and while loop would be the way to go or not.
Question by:stakor
    LVL 84

    Accepted Solution

    {local $/="</a>";
     while( <> ){
       print "$1\n" if /<a href="offsite_quotes.asp\?content=.*?>(.*)/s;

    Author Comment

    Thank you very much.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (,  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
    In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
    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…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now