Regex 用于在组中捕获数字的sed正则表达式
输入: 期望输出:Regex 用于在组中捕获数字的sed正则表达式,regex,Regex,输入: 期望输出: "//*[@id='headeritems1']": { "type": "checkbox", "value": "", "selectorType": "xpath" }, "//*[@id='headeritems3']": { "type": "exitPopUp", "value": "", "selec
"//*[@id='headeritems1']": {
"type": "checkbox",
"value": "",
"selectorType": "xpath"
},
"//*[@id='headeritems3']": {
"type": "exitPopUp",
"value": "",
"selectorType": "xpath"
我如何在组中捕获数字标题1和3,而不替换它
我使用的正则表达式:
"(//*[@id='headeritems1'])[2]": {
"type": "checkbox",
"value": "",
"selectorType": "xpath"
},
"(//*[@id='headeritems3'])[2]": {
"type": "exitPopUp",
"value": "",
"selectorType": "xpath"
我试过了你的意见。查看并让我知道这是否是您的预期输出。你好,Sonal,欢迎来到Stack Overflow!将来,您能否使用'backticks'将某些内容格式化为
code
?对于多行代码,每行还可以使用四个空格。无论哪种方式,只要突出显示问题编辑器中的代码,然后单击带括号的按钮,如:{}。谢谢要解析json文件,sed是错误的工具,请使用jq。
sed -i "s/\/\/\*\[@id='headeritems[(\d)]'\]/\"(\/\/\*\[@id='headeritems\1'\])\[2\]/g"