Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 正则表达式使用preg_match替换网页元描述撇号_Php_Regex_Preg Match - Fatal编程技术网

Php 正则表达式使用preg_match替换网页元描述撇号

Php 正则表达式使用preg_match替换网页元描述撇号,php,regex,preg-match,Php,Regex,Preg Match,我有以下数据: <meta name="description" content="Access Kenya is Kenya's leading corporate Internet service provider and is a technology solutions provider in Kenya with IT and network solutions for your business.Welcome to the Yellow Network.Kenya's lea

我有以下数据:

<meta name="description" content="Access Kenya is Kenya's leading corporate Internet service provider and is a technology solutions provider in Kenya with IT and network solutions for your business.Welcome to the Yellow Network.Kenya's leading Corporate and Residential ISP" />;
我正在使用这个正则表达式:

<meta +name *=[\"']?description[\"']? *content=[\"']?([^<>'\"]+)[\"']?

<代码> 您的正则表达式考虑了<代码> <代码>节点的三个选项:

<meta name="description" content="Some Content" />
<meta name='description' content='Some Content' />
<meta name=description content=Some Content />

但是,同样在这种情况下,如果你有这个meta,会发生什么呢

<meta content="Some Content" name="description" />
将输出:

Some Content
是的,它是5行vs 1,但是使用此方法,您将匹配任何
(如果它包含第三个无效属性,也可以)


  • 阅读更多关于
  • 阅读更多关于
  • 阅读

。。。如果属性值用单引号括起来,那么匹配双引号也会有同样的问题,对吗?此外,你还可以考虑一个没有引号的元的(不可能)选项。fusion3k我有一个后备计划,谢谢你
Some Content