0

我有一部分字符串(下面的示例)

'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....

我只想搜索每个消息标签(“message”:“msg here”})并在开始时添加一些文本,在匹配结束时添加一些文本,如下所示。

'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

我怎样才能在正则表达式的帮助下做到这一点?我正在使用带有目标平台 .NET 2.0 的 Visual Basic 2010。

4

1 回答 1

1
yourstr=Regex.Replace(yourstr,@"("")message\1:\1[^\1]*?\1}","<bound>$0</bound>");
于 2013-08-29T09:38:49.113 回答