编辑代码

 const templatePathMapping = {
  taskForm: '^/app/:appId/renderDetail/taskForm/:mode/:formId/:bizId$',
  flowTodoForm: '^/app/:appId/renderDetail/flowTodoForm/:mode/:flowId$',
  flowDoneForm: '^/app/:appId/renderDetail/flowDoneForm/:mode/:flowId$',
  flowRegisterForm: '^/app/:appId/renderDetail/flowRegisterForm/:mode/:flowId$'
}
 function getParamsKeys (str = '') {
const regex = /(:\w+/g;
  const replaceStr = '(.*?)'
  let matches = regex.exec(str) || []
  let arr = []

  let regStr = str
  while (matches) {
    console.log(matches, 'matches')
    let matchStr = matches[2] || matches[4]
    arr.push(matchStr)
    regStr = regStr.replace(matchStr, replaceStr)
    matches = regex.exec(str)
  }
  return {
    keys: arr,
    regStr: regStr
  }
}
console.log(getParamsKeys('^/app/:appId/renderDetail/taskForm/:mode/:formId/:bizId$'))