regex -replace crochet + saut de ligne
Bonjour à tous, je souhaite replacer deux crochets avec saut de ligne en powershell, sur mon regex101 ca match bien, mais dans mon code powershell ca ne semble pas fonctionner aurai je oublié un élément ?
Code:
1 2 3 4 5 6
| [
"{\n\"id\": GROSPC14022020,\n\"name\":\"GROSPC\",\n\"date\":14022020,\n\"url\":[\"\\hosts\\GROSPC\\security\\14022020security.json\",\n\"\\hosts\\GROSPC\\application\\14022020application.json\", \n\"\\hosts\\GROSPC\\system\\14022020system.json\"]\n}"
]
[
"{\n\"id\": GROSPC14022020,\n\"name\":\"GROSPC\",\n\"date\":14022020,\n\"url\":[\"\\hosts\\GROSPC\\security\\14022020security.json\",\n\"\\hosts\\GROSPC\\application\\14022020application.json\", \n\"\\hosts\\GROSPC\\system\\14022020system.json\"]\n}"
] |
Doit devenir
Code:
1 2 3 4
| [
"{\n\"id\": GROSPC14022020,\n\"name\":\"GROSPC\",\n\"date\":14022020,\n\"url\":[\"\\hosts\\GROSPC\\security\\14022020security.json\",\n\"\\hosts\\GROSPC\\application\\14022020application.json\", \n\"\\hosts\\GROSPC\\system\\14022020system.json\"]\n},"
"{\n\"id\": GROSPC14022020,\n\"name\":\"GROSPC\",\n\"date\":14022020,\n\"url\":[\"\\hosts\\GROSPC\\security\\14022020security.json\",\n\"\\hosts\\GROSPC\\application\\14022020application.json\", \n\"\\hosts\\GROSPC\\system\\14022020system.json\"]\n}"
] |
Ci dessous vers mon regex101 "normalement" fonctionnel
https://regex101.com/r/2X4LE2/2
L'objectif étant de passer de multiples tableaux à un unique
Code:
1 2
| $PathRender = "C:\datas\render\render.json"
[IO.File]::ReadAllText($PathRender) -replace '/("\n\]\n\[\n )/gmi','," ' | Set-Content $PathRender |