[英].NET RegEx replace escape character with tag
I have some text from an old database. 我有一些来自旧数据库的文本。 The text is formatted like this:
文本格式如下:
This is the first part of the text #this should be formatted in bold# this should be normal text and then #this should be formatted in bold again# and so on.
这是文本的第一部分#this应该用粗体格式化#这应该是普通文本然后#this应该再用粗体格式化#等等。
As you can see above, I need to find all the groups that are inside # signs, and set a <b></b>
or <strong></strong>
tag around them. 如您所见,我需要找到#符号内的所有组,并在它们周围设置
<b></b>
或<strong></strong>
标记。 How can I do this in C#? 我怎么能在C#中做到这一点?
string input = @"This is the first part of the text #this should be formatted in bold# this should be normal text and then #this should be formatted in bold again# and so on.";
var output = Regex.Replace(input, @"#(.+?)#", "<b>$1</b>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.