我们可以用拆分器拆分输入字符串吗 /* ! */
我有绳子
var a ="/*! ###################################################### # Test.cs # RELEASE: 1.1.1 # BUILD DATE: Fri Oct 30 2020 15:25:57 GMT-0700 (PDT) # COPYRIGHT ###################################################### *//*! MISC + SASS */a:focus,button:focus,div[tabindex]:focus,li[tabindex]:focus,span[tabindex]:focus{outline-offset:2px;outline-width:2px!important;outline-style:dotted!important;outline-color:currentColor}/*! GENERIC - BGIMG */.bgimg{background-size:cover;background-position:50% 50%;background-repeat:no-repeat}/*! CG2111 - test */span{color:red}/*! CG2112 - test */span{color:red}/*! INFO */#id{content:'1.1.1'}"
我正在尝试使用注解代码拆分字符串 /* ! */
预期产量
{
"MISC + SASS " : "span[tabindex]:focus,
li[tabindex]:focus,
div[tabindex]:focus,
button:focus,
a:focus {
outline-offset: 2px;
outline-width: 2px !important;
outline-style: dotted !important;
outline-color: currentColor;
}",
"GENERIC - BGIMG":".bgimg {
background-size: cover;
background-position: 50% 50%;
background-repeat: no-repeat;
}",
"CG2111 - test":"span {
color: red;
}",
"CG2112 - test":"span {
color: red;
}",
"INFO":"#id {
content: '1.1.1';
}"
}
或仅存储在数组中的值。
2条答案
按热度按时间eqfvzcg81#
下面是一种使用正则表达式根据
/*! ... */
结构。ssm49v7z2#
假设序列
*//*!
将始终是字符串的一部分(就在预期结果开始之前):