其中":56px"是未知的,我结果希望replace之后是这样的height:12px;background:#fff;,下面是我写的,会把width后面的全部删掉的
var str = "height:12px;width:56px;background:#fff;";
str.replace(RegExp('width.*;'),'');
//=>height:12px;
其中":56px"是未知的,我结果希望replace之后是这样的height:12px;background:#fff;,下面是我写的,会把width后面的全部删掉的
var str = "height:12px;width:56px;background:#fff;";
str.replace(RegExp('width.*;'),'');
//=>height:12px;
4 回答970 阅读
1 回答859 阅读✓ 已解决
1 回答1.1k 阅读
1 回答651 阅读✓ 已解决
2 回答779 阅读
2 回答622 阅读
1 回答828 阅读
str.replace(RegExp('width[^;]*;'),'');