Home  >  Article  >  Backend Development  >  Positive value expression matches the attribute value of html tag, expression attribute value_PHP tutorial

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

WBOY
WBOYOriginal
2016-07-12 08:58:351200browse

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:

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

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

$circle is the content of the circle tag above

preg_match_all('/386a0e0ab44031b4c6981a610c5bcfc1]*?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>

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:...
Statement:
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