HTML 字符串是:
"<div>\r\n<video controls=\"controls\" height=\"313\" id=\"video201643154436\" poster=\"/uploads/ckeditor/pictures/18/content_56883622_18f242e114.jpg\" width=\"500\"><source src=\"/uploads/ckeditor/attachments/23/newtons_law.mp4\" type=\"video/mp4\" />Your browser doesn't support video.<br />\r\nPlease download the file: <a href=\"/uploads/ckeditor/attachments/23/newtons_law.mp4\">video/mp4</a></video>\r\n</div>\r\n\r\n<div>test description</div>\r\n\r\n<div>\r\n<div>\r\n<video controls=\"controls\" height=\"300\" id=\"video201644152011\" poster=\"\" width=\"400\"><source src=\"/uploads/ckeditor/attachments/24/test.mp4\" type=\"video/mp4\" />Your browser doesn't support video.<br />\r\nPlease download the file: <a href=\"/uploads/ckeditor/attachments/24/test.mp4\">video/mp4</a></video>\r\n</div>\r\n\r\n<p> </p>\r\n</div>\r\n"
我想将所有视频标签(包括其内容和子标签)替换为[[ Video ]]
预期的输出是:
"<div>\r\n[[ Video ]]\r\n</div>\r\n\r\n<div>test description</div>\r\n\r\n<div>\r\n<div>\r\n[[ Video ]]\r\n</div>\r\n\r\n<p> </p>\r\n</div>\r\n"
我曾尝试使用 regex /<video\s(.*?)<\/video(?=[>])>/
,但它无法正常工作。