我如何使用正则表达式? (PHP)

I need to scrap data from a page, and the source code in the file is like this:

                <td class="pl-15">
                                            <a class="job-item" id="job-92837" href="http://www.jobs.com/job/looking-for-c-and-net-rockstar-developers/92837" >
                        Looking Rockstar Developers!                        </a>


                </td>
                <td >

                    <a href="http://www.jobs.com/employer/spidron/7388" class="joblist">    

                        Spidron                                             </a>

The Pattern i used is like this simply:

        $pattern = '/<a class="job-item" id="(.*?)" href="(.*?)">(.*?)\/a>/';

        preg_match_all($pattern, $content, $matches);

The problem with this pattern is that i get data in the thirds array like:

                Looking for Rockstar Developers!                        </a>


                </td>
                <td >

                    <a href="http://www.jobs.com/employer/spidron/7388" class="joblist">    

                        Spidron     

How do i get "Looking for Rockstar Developers!" in one array, the following link "http://www.jobs.com/employer/spidron/7388" in another array, and "Spidron" in another.

Just a beginner in using regular expression, help is much appreciated. :)

You have two problems here:

  1. Your data spans across multiple lines. Therefore you should add 's' at the end of your regex.
  2. You have a space before the closing tag. You should take it into consideration.

Use this regex instead:

$pattern = '/\<a class="job-item" id="(.*?)" href="(.*?)".*>(.*?)<\/a>/s';