Home > Backend Development > PHP Tutorial > A brief discussion on how to extract image addresses using php regular rules

A brief discussion on how to extract image addresses using php regular rules

WBOY
Release: 2016-07-25 08:58:00
Original
985 people have browsed it
This article introduces how to use PHP regular expressions to extract the image address in the page. Friends in need can refer to it.

In html pages, the html code of the image URL specification is generally: A brief discussion on how to extract image addresses using php regular rules 囧2 and 囧4 are optional, but 囧1, A brief discussion on how to extract image addresses using php regular rules, 囧5, and 囧6 are essential to pass XHTML authentication. If we talk about regularity, the shortest match is: (?

However, this will report an error in php: Warning: preg_match_all() [function.preg-match-all]: Compilation failed: lookbehind assertion is not fixed length at offset *** in ***

The problem is in the zero-width assertion (? Copy code Code example: (?Simple (?

Is it okay to list the suffixes of the pictures? For example:

Copy code Code example: (?Have you ever seen a picture without a suffix? jbxue.com has many such examples RAW http://us.jbxue.com/content/media/images/Headers/15559182 SmackDown http://us.jbxue.com/content/media/images/Headers/15854138 NXT http://us.jbxue.com/content/media/images/Headers/15929136 Superstars http://us.jbxue.com/content/media/images/Headers/15815850

The URLs above are all pictures, but none of them have traditional suffixes. When encountering such addresses, you will still be at a loss.

At this point, you can do this: A brief discussion on how to extract image addresses using php regular rules

Suggestions on php regular extraction of image addresses: If the format of the image address is img space src=, please use: (?

Let’s just introduce these. The writing is a bit messy, but I really hope it can help everyone understand the usage of PHP regularization.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template