如果它们在数组中相邻,则合并I和J. [英] Merge I and J if they are next to each in array.
问题描述
我有一个小问题.我正在创建荷兰文字游戏.唯一的问题是荷兰语很奇怪.它作为"ij"表示.但是,它的语法不是字母.
我想做的是:如果在数组中每个I和J旁边(仅在I和J不切换时),则应将它们合并到1个索引中.所以:
I have a slight problem. I'm creating a Dutch word game. The only issue is that the Dutch language is strange. It as an "ij" in its grammatics, although, it's not in the alphabet.
What I would like to do: If in an array an I and J next to each are (only at I and J not switched), then they should be merged in 1 index. So:
如果单词(表单文本文档)是IJSBEER(表示icebear). I-J-S-B-E-E-R被拆分,然后通常包含7个字母,但是在这种情况下,我想合并I和J,所以它必须是IJ-S-B-E-E-R.
If the word (form text document) is IJSBEER (means icebear). I-J-S-B-E-E-R is split and then it would contain 7 letters normally, but in this case I want to merge the I and J so it's need to be IJ-S-B-E-E-R.
[0] IJ
[1] S
[2] B
[3] E
[4] E
[5] R
我现在正在做的是以下事情:
What I'm doing right now is the following:
公共静态字符串first_word = File
.ReadLines(@"C:Path/nl_5.txt")
.Skip(word_number-1)
.FirstOrDefault();
公共字符串[] mistery_word = first_word.Select(c => c.ToString()).ToArray(); (分割文本文件中的单词)
public static string first_word = File
.ReadLines(@"C:Path/nl_5.txt")
.Skip(word_number - 1)
.FirstOrDefault();
public string[] mistery_word = first_word.Select(c => c.ToString()).ToArray(); (splitting the text file word)
在拆分之前或之后,如何检查I和J是否相邻,如果合并,将它们合并为1.
How could I check, before or after splitting, if the I and J are next to each and if so, merge them to 1.
推荐答案
也许将"I replaceJ"替换为单个字母IJ"(Unicode)更合适编码为U + 0132的字符? (也有一个小写的变体).一个例子:
字符串 text = "IJSBEER" //七个字符
string text = "IJSBEER"; // seven characters
字符串 result = text.Replace( "IJ" "\ u0132"" //六个字符
string result = text.Replace( "IJ", "\u0132" ); // six characters
这篇关于如果它们在数组中相邻,则合并I和J.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!