脚本
const {exec} = require('child_process'); const iconv = require('iconv-lite'); let str = ` <head> <style> * { padding: 0; margin: 0; } </style> <style> li { list-style: none; } </style> </head> ` let arr = [] str.replace(/<style.*>( |.)*</style>/gim, s => { arr.push(s) }) let arr2 = [] for (let i = 0, len = arr.length; i < len; i++) { let v = arr[i] v = v.replace(/<style.*>/gim, '') v = v.replace(/</style>/gim, '') arr2.push(v) } let str2 = arr2.join(" ") exec('clip').stdin.end(iconv.encode(str2.trim(), 'gbk')); console.log('===复制成功===', new Date().toLocaleString())
结果
* { padding: 0; margin: 0; } li { list-style: none; }
本文地址
https://www.cnblogs.com/stumpx/p/15161107.html
===