正则表述提取标签属性值
正则表达提取标签属性值
如何用正则表达是提title的值“The Amazing Spider-Man (2012)”呢?
我自己是用两次preg_split取的,但感觉很低效,有没有朋友给点思路呢?
- HTML code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><td class="image"> <a href="/title/tt0948470/" title="The Amazing Spider-Man (2012)"><img src="/static/imghw/default1.png" data-src="http://ia.media-imdb.com/images/M/MV5BMjMyOTM4MDMxNV5BMl5BanBnXkFtZTcwNjIyNzExOA@@._V1._SX54_CR0,0,54,74_.jpg" class="lazy" style="max-width:90%" style="max-width:90%" alt="The Amazing Spider-Man (2012)" title="The Amazing Spider-Man (2012)"></a> </td>
------解决方案--------------------
- PHP code
<?php $str='<td class="image"> <a href="/title/tt0948470/" title="The Amazing Spider-Man (2012)"><img src="/static/imghw/default1.png" data-src="http://ia.media-imdb.com/images/M/MV5BMjMyOTM4MDMxNV5BMl5BanBnXkFtZTcwNjIyNzExOA@@._V1._SX54_CR0,0,54,74_.jpg" class="lazy" style="max-width:90%" style="max-width:90%" alt="The Amazing Spider-Man (2012)" title="The Amazing Spider-Man (2012)"></a> <a href="/title/tt0948470/" title="The Amazing Spider-Man (2012)"> ';$patten = '/title="(.*)"/Uis';if (preg_match ( $patten, $str, $array )) {print_r($array);}echo "<br>";$patten1 = '/</a><a href=".*" title="(.*)">/Uis';if (preg_match_all ( $patten1, $str, $array1 )) {print_r($array1[1]);}?><br><font color="#e78608">------解决方案--------------------</font><br><dl class="code">PHP code<pre class="brush:php;toolbar:false">$string='<td class="image"> <a href="/title/tt0948470/" title="The Amazing Spider-Man (2012)1"><img src="/static/imghw/default1.png" data-src="http://ia.media-imdb.com/images/M/MV5BMjMyOTM4MDMxNV5BMl5BanBnXkFtZTcwNjIyNzExOA@@._V1._SX54_CR0,0,54,74_.jpg" class="lazy" style="max-width:90%" style="max-width:90%" alt="The Amazing Spider-Man (2012)" title="The Amazing Spider-Man (2012)3"></a><a href="/title/tt0948470/" title="The Amazing Spider-Man (2012)2"></a> </td>'; if (preg_match_all ( '/(?array(2) { [0]=> array(3) { [0]=> string(38) "title="The Amazing Spider-Man (2012)1"" [1]=> string(38) "title="The Amazing Spider-Man (2012)3"" [2]=> string(38) "title="The Amazing Spider-Man (2012)2"" } [1]=> array(3) { [0]=> string(30) "The Amazing Spider-Man (2012)1" [1]=> string(30) "The Amazing Spider-Man (2012)3" [2]=> string(30) "The Amazing Spider-Man (2012)2" }} */<div class="clear"> </div>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Title is the meaning that defines the title of the web page. It is located within the tag and is the text displayed in the title bar of the browser. Title is very important for the search engine optimization and user experience of the web page. When writing HTML web pages, you should pay attention to using relevant keywords and attractive descriptions to define the title element to attract more users to click and browse.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

The title in HTML displays the title tag of the web page, which allows the viewer to know what the current page is about, so each web page should have a separate title.

phpSpider practical tips: How to deal with dynamic loading of web content? When crawling web page data, we often encounter the problem that dynamically loaded content cannot be obtained directly through the crawler. These dynamically loaded contents can be data obtained through AJAX requests, DOM elements rendered through JavaScript, etc. In order to solve this problem, this article will introduce some practical tips for dealing with dynamic loading problems of web pages when using phpSpider. 1. Use network debugging tools to find dynamically loaded URLs

Scrapy is a powerful web crawler framework written in Python. It can help us extract web page information, automatically operate the content and data on the website, and can handle large-scale data crawling and processing tasks in a very efficient manner. Scrapy provides a powerful Spider framework, API and plug-ins for easy use and extension. In this article, we will introduce how to support multiple web page parsing methods in ScrapySpider. Before we start, we need to understand some basics

phpSpider Advanced Guide: How to implement data crawling that maintains login status? In recent years, with the rapid development of the Internet, data crawling plays an important role in various application scenarios. For some websites that require a login state, it is particularly important to implement data crawling in the login state. This article will introduce how to use phpSpider to implement data crawling that maintains login status, and give corresponding code examples. 1. Overview phpSpider is a high-performance, low-coupling, and support system developed based on PHP language.

Getting started with phpSpider: How to crawl web content easily? Introduction: In today's Internet era, a large amount of information is scattered on various web pages. If we can automatically extract the required information from these web pages, our work efficiency will be greatly improved. So how to achieve this goal? The answer is to use crawler technology. This article will introduce how to use phpSpider to crawl simple web content, let’s take a deeper look! 1. What is phpSpider? phpSpider is

图片消失如何解决先是图片文件上传$file=$_FILES['userfile']; if(is_uploaded_file($file['tmp_name'])){$query=mysql_query("INSERT INTO gdb_banner(image_src ) VALUES ('images/{$file['name'
