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 ?
Doit devenir
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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}" ]
Ci dessous vers mon regex101 "normalement" fonctionnel
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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}" ]
https://regex101.com/r/2X4LE2/2
L'objectif étant de passer de multiples tableaux à un unique
Code PowerShell : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 $PathRender = "C:\datas\render\render.json" [IO.File]::ReadAllText($PathRender) -replace '/("\n\]\n\[\n )/gmi','," ' | Set-Content $PathRender
Partager