Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一些来自旧数据库的文本。文本格式如下:
这是文本的第一部分#this 应该用粗体格式化#这应该是普通文本然后#this 应该再次用粗体格式化#等等。
正如您在上面看到的,我需要找到 # 符号内的所有组,并在它们周围设置一个<b></b>或<strong></strong>标记。我怎样才能在 C# 中做到这一点?
<b></b>
<strong></strong>
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>");