Question

I have part of string (Sample Below)

'another string string string....

"message":"test message 1 abcd xyz"}

"message":"test message 2 123 xyz bla bla"}

"message":"msg message msg etc xyz bla xyz"}

'other string string string....

I just want to search each message tag ("message":"msg here"}) and add some text in start and some text at the end of the match like this.

'another string string string.... as it is

<bound>"message":"test message 1 abcd xyz"}</bound>

<bound>"message":"test message 2 123 xyz bla bla"}</bound>

<bound>"message":"msg message msg etc xyz bla xyz"}</bound>

'other string string string.... as it is

How can I do this with the help of regex? I Am using visual basic 2010 with targeted platform .NET 2.0.

Was it helpful?

Solution

yourstr=Regex.Replace(yourstr,@"("")message\1:\1[^\1]*?\1}","<bound>$0</bound>");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top