0
用正则表达式,并在PowerShell中使用它,我想找到一个json的特定领域的所有反斜线,其它字段值必须被忽略正则表达式:找到多个结果在JSON,但只能在特定的领域,忽略其他领域
例:查找 “查找” 字段中的所有backslases,但不是在更换领域inthis源
{
"Find" : "<HintPath>([\.]{2}\\){1}Common\\Debug\\",
"Replace": "<HintPath>..\Common\Release\"
},
{
"Find" : "<HintPath>([\.]{2}\\){2}Common\\Debug\\",
"Replace": "<HintPath>..\..\Common\Release\"
},
{
"Find" : "<HintPath>([\.]{2}\\){3}Common\\Debug\\",
"Replace": "<HintPath>..\..\..\Common\Release\"
},
{
"Find" : "<HintPath>([\.]{2}\\){4}Common\\Debug\\",
"Replace": "<HintPath>..\..\..\..\Common\Release\"
},
{
"Find" : "<HintPath>([\.]{2}\\){5}Common\\Debug\\",
"Replace": "<HintPath>..\..\..\..\..\Common\Release\"
},
{
"Find" : "<HintPath>([\.]{2}\\){6}Common\\Debug\\",
"Replace": "<HintPath>..\..\..\..\..\..\Common\Release\"
}
这并没有为我工作:
(?<="Find")\\(?=\",)
尝试['(?m)(?:\ G(?!\ A)|^\ s *“Find”)\ [^ \\\ n \] * \ ķ\\\'](https://regex101.com/r/pWvCib/1)。 –
that works :)如果你能详细解释正则表达式,这将是非常好的吗?谢谢 –
编辑:如果我删除“,”和“替换”之间的换行符,它仍然匹配替换字段中的所有反斜杠。我们可以以某种方式避免吗? –