Positive value expression matches the attribute value of html tag, expression attribute value_PHP tutorial

WBOY
Release: 2016-07-12 08:58:35
Original
1200 people have browsed it

Positive expression matches the attribute value of the html tag, and the expression attribute value

Today, due to work requirements, I need to obtain the attribute value of the html tag, and I immediately thought of regular expressions , the tags are as follows:


< ;circle id="ap_test" cx="201" cy="2001" r="2" stroke="black" stroke-width="0" fill="red"/>

I need to get the cx and cy attribute values ​​​​of the tag. I thought for a while and wrote one:

$circle is the content of the circle tag above

preg_match_all('/]*?cxs*=s*('|")(.*?)\1[^>]*?cys*=s *('|")(.*?)\1[^>]*?/?s*>/i', $circle, $arr);

var_dump($arr);

$arr[2] is the value of cx, $arr[4] is the value of cy.

<span id="line25"><span id="line26"><span id="line27"><span id="line28"><span id="line29"><span id="line30"><span id="line31"><span id="line32"><span id="line33"><span id="line34"><br /><br /></span></span></span></span></span></span></span></span></span></span>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1102844.htmlTechArticlePositive expression matches the attribute value of the html tag. The expression attribute value needs to be obtained due to work requirements today. For the attribute value of the label, regular expressions immediately come to mind. The label is as follows:...
Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!