Мне необходимо из HTML удалить все атрибуты и содержимое тегов, кроме других вложенных в них тегов. Есть HTML для примера:
<html>
<head>
<meta charset="utf-8">
<title data-react-helmet="true"></title>
<meta data-react-helmet="true" name="google-site-verification" content="oK1wxWd6PmSRXPig-5hI0KACVm0ITZ4E9cgRYCCbI8I">
<meta data-react-helmet="true" name="robots" content="noindex,nofollow">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png">
<link rel="icon" type="image/vnd.microsoft.icon" href="/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/assets/icons/favicon-120x120.png">
<link rel="icon" type="svg+xml" sizes="120x120" href="/assets/svg/favicon.svg">
<link rel="preconnect" href="https://login4play.com" as="script" crossorigin="">
<link rel="preload" href="/assets/svg/preload.svg" as="image">
<link data-chunk="RegisterPage" rel="preload" as="style" href="/public/621bc7bf/72.css">
<link data-chunk="RegisterPage" rel="preload" as="style" href="/public/621bc7bf/6.css">
<link data-chunk="RegisterPage" rel="preload" as="style" href="/public/621bc7bf/2.css">
<link data-chunk="RegisterPage" rel="preload" as="style" href="/public/621bc7bf/0.css">
<link data-chunk="RegisterPage" rel="preload" as="style" href="/public/621bc7bf/1.css">
<link data-chunk="Fonts-Web" rel="preload" as="style" href="/public/621bc7bf/37.css">
<link data-chunk="app" rel="preload" as="style" href="/public/621bc7bf/app.css">
<link data-chunk="app" rel="preload" as="script" href="/public/621bc7bf/bundle.9a5f28e5.js">
<link data-chunk="Fonts-Web" rel="preload" as="script" href="/public/621bc7bf/chunk.e5c3fc65.js">
<link data-chunk="RegisterPage" rel="preload" as="script" href="/public/621bc7bf/chunk.427f1bb7.js">
<link data-chunk="RegisterPage" rel="preload" as="script" href="/public/621bc7bf/chunk.3db28734.js">
<link data-chunk="RegisterPage" rel="preload" as="script" href="/public/621bc7bf/chunk.8c693f24.js">
<link data-chunk="RegisterPage" rel="preload" as="script" href="/public/621bc7bf/chunk.578ca88f.js">
<link data-chunk="RegisterPage" rel="preload" as="script" href="/public/621bc7bf/chunk.9c5f909f.js">
<link data-chunk="app" rel="stylesheet" href="/public/621bc7bf/app.css">
<link data-chunk="Fonts-Web" rel="stylesheet" href="/public/621bc7bf/37.css">
<link data-chunk="RegisterPage" rel="stylesheet" href="/public/621bc7bf/1.css">
<link data-chunk="RegisterPage" rel="stylesheet" href="/public/621bc7bf/0.css">
<link data-chunk="RegisterPage" rel="stylesheet" href="/public/621bc7bf/2.css">
<link data-chunk="RegisterPage" rel="stylesheet" href="/public/621bc7bf/6.css">
<link data-chunk="RegisterPage" rel="stylesheet" href="/public/621bc7bf/72.css">
</head>
<body>
<div class="WebRoot" id="root">
<noscript>&lt;iframe src={`https://www.googletagmanager.com/ns.html?id=GTM-KW7NGVZ`}
height=&quot;0&quot; width=&quot;0&quot; style=&quot;display:none;visibility:hidden&quot;&gt;&lt;/iframe&gt;
</noscript>
<div class="layout layout--desktop">
<div class="wrap___pwD07">ПРИВЕТ ВСЕМ</div>
</div>
</div>
<script>window.__INITIAL_STATE__</script>
</body>
</html>
В итоге, мне нужно получить что-то типо такого. Как это сделать? Регулярку написать неполучается(:
<html>
<head>
<meta>
<title></title>
<meta>
<meta>
<meta>
<meta>
<meta>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
<link>
</head>
<body>
<div>
<noscript></noscript>
<div>
<div></div>
</div>
</div>
<script></script>
</body>
</html>