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 :)如果你能詳細解釋正則表達式,這將是非常好的嗎?謝謝 –
編輯:如果我刪除「,」和「替換」之間的換行符,它仍然匹配替換字段中的所有反斜槓。我們可以以某種方式避免嗎? –