您好,这是 HTML 代码
<html>
<head>
<link rel="stylesheet" type="text/css" href="Theme.css">
</head>
<body>
<div>
<textarea id="ta" onpaste="functionItalic(event)" class="foostyle2"></textarea>
</div>
<div>
<span style="font-weight: bolder; font-size: 20px;">
<span id="1">Karan's</span>
</span>
<span style="font-weight: bolder; font-size: 24px; font-style: italic;">test</span>
</div>
<script>
function functionItalic(pasteEvent)
{
var textareacont = (pasteEvent.originalEvent || pasteEvent).clipboardData.getData("text/html");
console.log(textareacont);
var styleSheetList = document.styleSheets;
document.getElementById("1").className = "foostyle";
var stringCSS = ".foostyle{font-family: Times-Roman;font-size:10pt;color:rgb(0,0,0);font-style:normal;}";
styleSheetList[0].insertRule(stringCSS, styleSheetList[0].cssRules.length);
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我运行这个文件时,一切正常并且样式被添加。
但是一旦我将 stringCSS 的值更改为
var stringCSS = ".foostyle{font-family: Times-Roman;font-size:10pt;color:rgb(0,0,0);font-style:normal;} .foostyle2{background: green;}";
Run Code Online (Sandbox Code Playgroud)
浏览器提供错误
SyntaxError: An invalid or illegal …Run Code Online (Sandbox Code Playgroud) 我在notepad ++中编辑一个包含数字的HTML文件
x
x.x
x.x.x
x.x.x.x
x.x.x.x.x
Run Code Online (Sandbox Code Playgroud)
小数位数可以是零或更多.
其中x是ex的任何数字:
1
or
1.2
or
3.4.1
or
401.23.5
Run Code Online (Sandbox Code Playgroud)
我想创建一个正则表达式来查找文件中的所有这些实例请帮忙
我试过以下正则表达式
For 5 Decimals [0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}
For 4 Decimals [0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}
For 3 Decimals [0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}
For 2 Decimals [0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}
For 1 Decimal [0-9]{1,4}\.[0-9]{1,4}
Run Code Online (Sandbox Code Playgroud)
我必须单独使用这个正则表达式我想创建一个普遍检测任何小数的所有出现的正则表达式