Hello folks,
I’ve got a HttpRequest Response which is string. I need to remove “\” character but i think it is escape character. That’s why String.Replace isn’t working.
This is my string:
"{\"totalCount\":31,\"items\":[{\"Tarih\":\"01-07-2024\",\"TP_DK_USD_A\":\"32.8262\",\"TP_DK_EUR_A\":\"35.1284\",\"UNIXTIME\":{\"$numberLong\":\"1719781200\"}},{\"Tarih\":\"02-07-2024\",\"TP_DK_USD_A\":\"32.6207\",\"TP_DK_EUR_A\":\"35.0939\",\"UNIXTIME\":{\"$numberLong\":\"1719867600\"}},{\"Tarih\":\"03-07-2024\",\"TP_DK_USD_A\":\"32.629\",\"TP_DK_EUR_A\":\"34.9759\",\"UNIXTIME\":{\"$numberLong\":\"1719954000\"}},{\"Tarih\":\"04-07-2024\",\"TP_DK_USD_A\":\"32.4929\",\"TP_DK_EUR_A\":\"34.9499\",\"UNIXTIME\":{\"$numberLong\":\"1720040400\"}},{\"Tarih\":\"05-07-2024\",\"TP_DK_USD_A\":\"32.5011\",\"TP_DK_EUR_A\":\"35.0933\",\"UNIXTIME\":{\"$numberLong\":\"1720126800\"}},{\"Tarih\":\"06-07-2024\",\"TP_DK_USD_A\":null,\"TP_DK_EUR_A\":null,\"UNIXTIME\":{\"$numberLong\":\"1720213200\"}},{\"Tarih\":\"07-07-2024\",\"TP_DK_USD_A\":null,\"TP_DK_EUR_A\":null,\"UNIXTIME\":{\"$numberLong\":\"1720299600\"}},{\"Tarih\":\"08-07-2024\",\"TP_DK_USD_A\":\"32.6301\",\"TP_DK_EUR_A\":\"35.3205\",\"UNIXTIME\":{\"$numberLong\":\"1720386000\"}},{\"Tarih\":\"09-07-2024\",\"TP_DK_USD_A\":\"32.6401\",\"TP_DK_EUR_A\":\"35.3604\",\"UNIXTIME\":{\"$numberLong\":\"1720472400\"}},{\"Tarih\":\"10-07-2024\",\"TP_DK_USD_A\":\"32.7362\",\"TP_DK_EUR_A\":\"35.4241\",\"UNIXTIME\":{\"$numberLong\":\"1720558800\"}},{\"Tarih\":\"11-07-2024\",\"TP_DK_USD_A\":\"32.8849\",\"TP_DK_EUR_A\":\"35.5812\",\"UNIXTIME\":{\"$numberLong\":\"1720645200\"}},{\"Tarih\":\"12-07-2024\",\"TP_DK_USD_A\":\"32.8473\",\"TP_DK_EUR_A\":\"35.6229\",\"UNIXTIME\":{\"$numberLong\":\"1720731600\"}},{\"Tarih\":\"13-07-2024\",\"TP_DK_USD_A\":null,\"TP_DK_EUR_A\":null,\"UNIXTIME\":{\"$numberLong\":\"1720818000\"}},{\"Tarih\":\"14-07-2024\",\"TP_DK_USD_A\":null,\"TP_DK_EUR_A\":null,\"UNIXTIME\":{\"$numberLong\":\"1720904400\"}},{\"Tarih\":\"15-07-2024\",\"TP_DK_USD_A\":null,\"TP_DK_EUR_A\":null,\"UNIXTIME\":{\"$numberLong\":\"1720990800\"}},{\"Tarih\":\"16-07-2024\",\"TP_DK_USD_A\":\"32.9069\",\"TP_DK_EUR_A\":\"35.8082\",\"UNIXTIME\":{\"$numberLong\":\"1721077200\"}},{\"Tarih\":\"17-07-2024\",\"TP_DK_USD_A\":\"33.0223\",\"TP_DK_EUR_A\":\"35.9882\",\"UNIXTIME\":{\"$numberLong\":\"1721163600\"}},{\"Tarih\":\"18-07-2024\",\"TP_DK_USD_A\":\"33.038\",\"TP_DK_EUR_A\":\"36.0984\",\"UNIXTIME\":{\"$numberLong\":\"1721250000\"}},{\"Tarih\":\"19-07-2024\",\"TP_DK_USD_A\":\"33.0389\",\"TP_DK_EUR_A\":\"36.1143\",\"UNIXTIME\":{\"$numberLong\":\"1721336400\"}},{\"Tarih\":\"20-07-2024\",\"TP_DK_USD_A\":null,\"TP_DK_EUR_A\":null,\"UNIXTIME\":{\"$numberLong\":\"1721422800\"}},{\"Tarih\":\"21-07-2024\",\"TP_DK_USD_A\":null,\"TP_DK_EUR_A\":null,\"UNIXTIME\":{\"$numberLong\":\"1721509200\"}},{\"Tarih\":\"22-07-2024\",\"TP_DK_USD_A\":\"33.0042\",\"TP_DK_EUR_A\":\"35.9251\",\"UNIXTIME\":{\"$numberLong\":\"1721595600\"}},{\"Tarih\":\"23-07-2024\",\"TP_DK_USD_A\":\"32.9441\",\"TP_DK_EUR_A\":\"35.8679\",\"UNIXTIME\":{\"$numberLong\":\"1721682000\"}},{\"Tarih\":\"24-07-2024\",\"TP_DK_USD_A\":\"32.8805\",\"TP_DK_EUR_A\":\"35.7444\",\"UNIXTIME\":{\"$numberLong\":\"1721768400\"}},{\"Tarih\":\"25-07-2024\",\"TP_DK_USD_A\":\"32.8106\",\"TP_DK_EUR_A\":\"35.5656\",\"UNIXTIME\":{\"$numberLong\":\"1721854800\"}},{\"Tarih\":\"26-07-2024\",\"TP_DK_USD_A\":\"32.9833\",\"TP_DK_EUR_A\":\"35.7759\",\"UNIXTIME\":{\"$numberLong\":\"1721941200\"}},{\"Tarih\":\"27-07-2024\",\"TP_DK_USD_A\":null,\"TP_DK_EUR_A\":null,\"UNIXTIME\":{\"$numberLong\":\"1722027600\"}},{\"Tarih\":\"28-07-2024\",\"TP_DK_USD_A\":null,\"TP_DK_EUR_A\":null,\"UNIXTIME\":{\"$numberLong\":\"1722114000\"}},{\"Tarih\":\"29-07-2024\",\"TP_DK_USD_A\":\"32.9586\",\"TP_DK_EUR_A\":\"35.7732\",\"UNIXTIME\":{\"$numberLong\":\"1722200400\"}},{\"Tarih\":\"30-07-2024\",\"TP_DK_USD_A\":\"32.9509\",\"TP_DK_EUR_A\":\"35.711\",\"UNIXTIME\":{\"$numberLong\":\"1722286800\"}},{\"Tarih\":\"31-07-2024\",\"TP_DK_USD_A\":\"33.0304\",\"TP_DK_EUR_A\":\"35.7612\",\"UNIXTIME\":{\"$numberLong\":\"1722373200\"}}]}"```
And this is my Regex.Replace method:
System.text.regularExpressions.Regex.Replace(myString, “([”+Chr(34)+“~?'#|&\/%*<>:])”, “”)
Finally it’s output:
"{totalCount31,items[{Tarih01-07-2024,TP_DK_USD_A32.8262,TP_DK_EUR_A35.1284,UNIXTIME{$numberLong1719781200}},{Tarih02-07-2024,TP_DK_USD_A32.6207,TP_DK_EUR_A35.0939,UNIXTIME{$numberLong1719867600}},{Tarih03-07-2024,TP_DK_USD_A32.629,TP_DK_EUR_A34.9759,UNIXTIME{$numberLong1719954000}},{Tarih04-07-2024,TP_DK_USD_A32.4929,TP_DK_EUR_A34.9499,UNIXTIME{$numberLong1720040400}},{Tarih05-07-2024,TP_DK_USD_A32.5011,TP_DK_EUR_A35.0933,UNIXTIME{$numberLong1720126800}},{Tarih06-07-2024,TP_DK_USD_Anull,TP_DK_EUR_Anull,UNIXTIME{$numberLong1720213200}},{Tarih07-07-2024,TP_DK_USD_Anull,TP_DK_EUR_Anull,UNIXTIME{$numberLong1720299600}},{Tarih08-07-2024,TP_DK_USD_A32.6301,TP_DK_EUR_A35.3205,UNIXTIME{$numberLong1720386000}},{Tarih09-07-2024,TP_DK_USD_A32.6401,TP_DK_EUR_A35.3604,UNIXTIME{$numberLong1720472400}},{Tarih10-07-2024,TP_DK_USD_A32.7362,TP_DK_EUR_A35.4241,UNIXTIME{$numberLong1720558800}},{Tarih11-07-2024,TP_DK_USD_A32.8849,TP_DK_EUR_A35.5812,UNIXTIME{$numberLong1720645200}},{Tarih12-07-2024,TP_DK_USD_A32.8473,TP_DK_EUR_A35.6229,UNIXTIME{$numberLong1720731600}},{Tarih13-07-2024,TP_DK_USD_Anull,TP_DK_EUR_Anull,UNIXTIME{$numberLong1720818000}},{Tarih14-07-2024,TP_DK_USD_Anull,TP_DK_EUR_Anull,UNIXTIME{$numberLong1720904400}},{Tarih15-07-2024,TP_DK_USD_Anull,TP_DK_EUR_Anull,UNIXTIME{$numberLong1720990800}},{Tarih16-07-2024,TP_DK_USD_A32.9069,TP_DK_EUR_A35.8082,UNIXTIME{$numberLong1721077200}},{Tarih17-07-2024,TP_DK_USD_A33.0223,TP_DK_EUR_A35.9882,UNIXTIME{$numberLong1721163600}},{Tarih18-07-2024,TP_DK_USD_A33.038,TP_DK_EUR_A36.0984,UNIXTIME{$numberLong1721250000}},{Tarih19-07-2024,TP_DK_USD_A33.0389,TP_DK_EUR_A36.1143,UNIXTIME{$numberLong1721336400}},{Tarih20-07-2024,TP_DK_USD_Anull,TP_DK_EUR_Anull,UNIXTIME{$numberLong1721422800}},{Tarih21-07-2024,TP_DK_USD_Anull,TP_DK_EUR_Anull,UNIXTIME{$numberLong1721509200}},{Tarih22-07-2024,TP_DK_USD_A33.0042,TP_DK_EUR_A35.9251,UNIXTIME{$numberLong1721595600}},{Tarih23-07-2024,TP_DK_USD_A32.9441,TP_DK_EUR_A35.8679,UNIXTIME{$numberLong1721682000}},{Tarih24-07-2024,TP_DK_USD_A32.8805,TP_DK_EUR_A35.7444,UNIXTIME{$numberLong1721768400}},{Tarih25-07-2024,TP_DK_USD_A32.8106,TP_DK_EUR_A35.5656,UNIXTIME{$numberLong1721854800}},{Tarih26-07-2024,TP_DK_USD_A32.9833,TP_DK_EUR_A35.7759,UNIXTIME{$numberLong1721941200}},{Tarih27-07-2024,TP_DK_USD_Anull,TP_DK_EUR_Anull,UNIXTIME{$numberLong1722027600}},{Tarih28-07-2024,TP_DK_USD_Anull,TP_DK_EUR_Anull,UNIXTIME{$numberLong1722114000}},{Tarih29-07-2024,TP_DK_USD_A32.9586,TP_DK_EUR_A35.7732,UNIXTIME{$numberLong1722200400}},{Tarih30-07-2024,TP_DK_USD_A32.9509,TP_DK_EUR_A35.711,UNIXTIME{$numberLong1722286800}},{Tarih31-07-2024,TP_DK_USD_A33.0304,TP_DK_EUR_A35.7612,UNIXTIME{$numberLong1722373200}}]}"
As you noticed, it’s a JSON and i need quotes, colons and dots. But this regex deletes all.
Can you help me please?