Find a semicolon that matches the next colon

margin-top:20px;font-size:12px;color:-sharp000;
for example, how to match to font-size:12px;


does not understand your topic, what is the semicolon before the next colon;
the content between two semicolons can be: / [^;\:] +: [^;\:] +; / g


var str = string.split (";) [2]


I think it should be to convert the style string into an object so that it is easy to find a little

.
function getStyleObj(styles){
    let obj = {}
    styles.split(';')
    .filter(style => !!style)
    .forEach((style)=>{
        
       let styleArr = style.split(':')
       obj[styleArr[0]]=styleArr[1]
    
    })
    
    return obj
}
const styleObj = getStyleObj('margin-top:20px;font-size:12px;color:-sharp000;')
console.log(styleObj)

{
    'color':"-sharp000",
    'font-size':"12px",
    'margin-top':"20px"
}
Menu