Parse inline CSS values with Regex?

前端 未结 4 1826
Happy的楠姐
Happy的楠姐 2021-01-19 03:57

I have such an inline CSS like this

color:#777;font-size:16px;font-weight:bold;left:214px;position:relative;top:70px

The CSS may

4条回答
  •  醉梦人生
    2021-01-19 04:34

    Let try this it will work fine

    str.replace(/(\w+[-]?\w+)(?=:)/gi,'\n[$1] => ').replace(/[:;]+/g,'')
    

提交回复
热议问题