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.
古いデータベースからのテキストがあります。テキストは次のようにフォーマットされます。
これはテキストの最初の部分です #これは太字でフォーマットする必要があります# これは通常のテキストである必要があります #これは再び太字でフォーマットする必要があります# など。
上記のように、# 記号の内側にあるすべてのグループを見つけて、それらの周りに<b></b>or<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>");