This is bold text, and this is emphasized text.
Visit the Hugo website!
This is some text. Idk.
a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
string input = "私[わたし]は大丈夫[だいじょうぶ]です";
string output = AddSpacesAroundKanjiReading(input);
Console.WriteLine(output);
}
static string AddSpacesAroundKanjiReading(string text)
{
// Regex pattern to match kanji+reading (e.g., 私[わたし])
string pattern = @"([\u4E00-\u9FAF\u3400-\u4DBF\uF900-\uFAFF]+)\[([^\]]+)\]";
string replacement = " $1[$2] ";
// Replace with spaces around kanji+reading
string spacedText = Regex.Replace(text, pattern, replacement);
// Remove extra spaces
return Regex.Replace(spacedText, @"\s+", " ").Trim();
}
}
|