SOURCE

// 原始字符串  
let str = "http://10.128.12.40:59782/qg/webapi";  

function extract(str){
    let reg = /\/(\w+)\/webapi/

    let match = reg.exec(str)

    if (match){
        console.log('子字符串:',match[1])
        if (match[1] == 'qg'){
            console.log('match')
        }
    }
}

//extract(str)

extract('/qg/webapi')

const reg = /\[(.*)\]/
let str2 = 'upgrade [manualtrade-zhengjx] failed'
const m = str2.match(reg)
//如果m不为空,说明有策略实例升级失败
if (m && m[1]){
    const failedInsIDArr = m[1].split(',')
    console.log(failedInsIDArr)
}
console 命令行工具 X clear

                    
>
console