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,但是使用此方法,您将匹配任何
(如果它包含第三个无效属性,也可以)
- 阅读更多关于
- 阅读更多关于
- 阅读
Some Content