我如何在其中使用正则表达式? (php)

How do i use regular expression in this? (php)

我需要从一个页面中抓取数据,文件中的源代码是这样的:

                <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>

我用的Pattern是这样简单的:

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

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

此模式的问题是我在三分之一数组中获取数据,如:

                Looking for Rockstar Developers!                        </a>


                </td>
                <td >

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

                        Spidron     

如何在一个数组中得到 "Looking for Rockstar Developers!", 以下 link“http://www.jobs.com/employer/spidron/7388”在另一个数组中,"Spidron" 在另一个数组中。

刚开始使用正则表达式,非常感谢帮助。 :)

你这里有两个问题:

  1. 您的数据跨越多行。因此,您应该在正则表达式的末尾添加 's'。
  2. 您在结束标记前有一个 space。你应该考虑一下。

改为使用此正则表达式:

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