I wanted to replace a part of string between a text in double quotes and comma using Regex. Suppose I have a string like :
{Name: {\\"before\\":'Aj', \\"after\\":'Ajay'} }
So I want to extract text between "before" :
and comma. ie Aj
and replace it with "Aj"
. and same way for after
text to get 'Ajay
and replace it with "Ajay"
.
Can anyone please help me on this using Regex?
how about replacing '
width "
string yourString = "{Name: {\"before\":'Aj', \"after\":'Ajay'} }";
yourString = yourString.Replace('\'', '"');
//result would be: {Name: {"before":"Aj", "after":"Ajay"} }
I don't know much about regex, but I hope this works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.