如何从字符串中删除 U+FE6B (﹫)? [已关闭]

问题描述 投票:0回答:2

当cs2的游戏聊天结构发生变化时,我遇到了问题。

我已经相应地更改了代码,但由于某种原因,我似乎无法让这些代码行工作:

/* removal of the team-chat location info. */
if (chatType == ChatType.Team)
{
    var idx = namePart.LastIndexOf('﹫'); // uFE6B

    if (idx != -1)
        namePart = namePart.Substring(0, idx).Trim();
}

像这样过滤是有效的:

/* filter out the massage */
if (!l.Contains("[ALL]") && !l.Contains("﹫")) // uFE6B
    continue;

这就是日志中的行的样子:

我已经尝试过使用 Unicode 转义序列,但没有成功。

c# string unicode trim
2个回答
1
投票

我不太确定你想要什么,但是如果你想从字符串中删除该字符,你可以使用正则表达式:

using System.Text.RegularExpressions; string input = "Your ﹫ string with ﹫ character"; // Regex pattern to match the character '﹫' (Unicode U+FE6B) string pattern = @"\uFE6B"; // Replace the matched character with an empty string string result = Regex.Replace (input, pattern, string.Empty);
    

0
投票
自己修复了它......发布问题后我意识到它希望修剪

chatType.Team

而不是
namePart

就像我爷爷常说的:

会读书的人优势明显

© www.soinside.com 2019 - 2024. All rights reserved.