GTM模块作者使用正则表达式插入GTM代码并动态更改页面源。由于错误的正则表达式,在我的特定情况下它打破了HTML。无法理解为什么他没有使用任何钩子。
<!--[if lt IE 7 ]> <body id="homepage" class="ie ie6 html front not-logged-in one-sidebar sidebar-second page-node page-node- page-node-603 node-type-panel tao">
<!-- Google Tag Manager -->
...............
<!-- End Google Tag Manager --> <![endif]-->
<!--[if IE 7 ]> <body id="homepage" class="ie ie7 html front not-logged-in one-sidebar sidebar-second page-node page-node- page-node-603 node-type-panel tao"> <![endif]-->
<!--[if IE 8 ]> <body id="homepage" class="ie ie8 html front not-logged-in one-sidebar sidebar-second page-node page-node- page-node-603 node-type-panel tao"> <![endif]-->
<!--[if IE 9 ]> <body id="homepage" class="ie ie9 html front not-logged-in one-sidebar sidebar-second page-node page-node- page-node-603 node-type-panel tao"> <![endif]-->
<!--[if !IE]><!--> <body id="homepage" class="html front not-logged-in one-sidebar sidebar-second page-node page-node- page-node-603 node-type-panel tao"> <!--<![endif]-->
插件代码(他们只是使用正则表达式替换HTML)
$children = preg_replace('@<body[^>]*>@', '$0' . $script, $children, 1);
如何修复正则表达式?提前谢谢。