我有很多电影(目前有 1000 部,但很容易达到 5000 部)。我想为电影设置“正确”的标题,这意味着将“A”、“An”、“The”移动到标题的末尾(即“The Chronicles of Narnia”变成“Chronicles of Narnia, The”)。
我可以用子字符串做一些 if 语句,但我正在寻找最有效/最快的方法来做到这一点。
建议?
最佳答案
string title = "The Chronicles of Narnia";
string newTitle = Regex.Replace(title, "^(the|a|an) (.*)$", "$2, $1", RegexOptions.IgnoreCase);
Console.WriteLine(newTitle);
关于c# - 更改字符串以将 "A"、 "An"、 "The"移动到 c# 中字符串末尾的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6661280/