Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 在IDE中只查找并替换正则表达式的一部分_Regex_Visual Studio Code_Find Replace - Fatal编程技术网

Regex 在IDE中只查找并替换正则表达式的一部分

Regex 在IDE中只查找并替换正则表达式的一部分,regex,visual-studio-code,find-replace,Regex,Visual Studio Code,Find Replace,我正在尝试用VS代码中的正则表达式修复格式错误的XML 问题代码是自动关闭标签。在项目构建时,这些将作为子项嵌套。所以我只需要一个简单的正则表达式模式来匹配某些元素(这里是多边形),而忽略其他元素 使用正则表达式模式: (?:\.[0-9]+\"\s)\/\> 我要搜索:包含小数点、数字和双引号结尾的标记。 我想替换:之后的一切 问题--它替换了整个部分,而不是第二个表达式()中的块 例如: ... <stop offset="1" stop-color="#7ccb13" /&

我正在尝试用VS代码中的正则表达式修复格式错误的XML

问题代码是自动关闭标签。在项目构建时,这些将作为子项嵌套。所以我只需要一个简单的正则表达式模式来匹配某些元素(这里是多边形),而忽略其他元素

使用正则表达式模式:

(?:\.[0-9]+\"\s)\/\>

我要搜索:包含小数点、数字和双引号结尾的标记。 我想替换:之后的一切

问题--它替换了整个部分,而不是第二个表达式()中的块

例如:

...
<stop offset="1" stop-color="#7ccb13" />
<stop offset="1" stop-color="#7ccb55" />
...
<polygon points="393.38 285.04 394.44 284.63 393.67 283.79 394.61 284.38 394.59 283.31 394.94 284.34 395.79 283.54 395.21 284.5 396.3 284.49 395.28 284.83 396.16 285.64 395.05 285.05 395.12 286.27 394.73 285.1 393.89 285.88 394.43 284.99 393.38 285.04" />
<polygon points="159.41 439.9 160.88 439.35 159.82 438.19 161.12 439.01 161.08 437.52 161.57 438.95 162.74 437.84 161.94 439.16 163.46 439.15 162.04 439.63 163.25 440.75 161.72 439.92 161.82 441.61 161.28 440 160.12 441.07 160.87 439.84 159.41 439.9" />
<polygon points="180.71 444.75 182.18 444.2 181.11 443.04 182.41 443.86 182.38 442.37 182.87 443.8 184.04 442.69 183.24 444.01 184.75 444 183.33 444.48 184.55 445.59 183.02 444.77 183.12 446.46 182.57 444.85 181.42 445.92 182.16 444.69 180.71 444.75" />
...
。。。
...
...

所需输出--结束标记: 我认为
()
应该有效,并用
$1>取代


删除正则表达式中的
?:
,并在替换开始时添加
$1
。您能给出上述示例输入的预期输出吗?这更符合逻辑,更简单!谢谢!