简体   繁体   English

如何将文本拆分为字符并获取包含每个第 n 个字符的文本? (也许在 Excel 中)

[英]How to split a text into characters and get a text including every nth character ? (Maybe in Excel)

Here's the problem: I have a text and I want it to be represented as separate texts that is made by characters mod n.问题是:我有一个文本,我希望它被表示为由字符 mod n 组成的单独文本。 For example text: "hfhshsseekbfe...", n=5, then first one "hsb..." (1st,6th,11th character from the original), second one "fsf..." (2nd,7th,12th character from the original) and so on.例如文本:“hfhshsseekbfe...”,n=5,然后是第一个“hsb...”(原始字符的第 1、6、11 个字符),第二个“fsf...”(第 2、7、12 个字符)原作中的人物)等等。 It will be simpler to write a program in cpp that reads and extracts needed information (modulo n characters) from a file and writes it down in a new.txt file.在 cpp 中编写一个从文件中读取和提取所需信息(模数字符)并将其写入 new.txt 文件的程序会更简单。 But I'm not a coder, I did some of coding for my Numerical Analysis course, but there wasn't any strings.但我不是编码员,我为我的数值分析课程做了一些编码,但没有任何字符串。 So maybe Excel have some algorithms to do it?那么也许 Excel 有一些算法可以做到吗?

In excel sheet, with ExcelO365 you can use Sequence() formula with MID() function like-在 excel 工作表中,使用ExcelO365 ,您可以使用带有MID() function 的Sequence()公式 -

=TEXTJOIN("",TRUE,MID(A1,SEQUENCE(LEN(A1),,1,5),1))

在此处输入图像描述

For second one just make Start Number parameter of Sequence() formula to 2 like对于第二个,只需将Sequence()公式的Start Number参数设为2即可

=TEXTJOIN("",TRUE,MID(A1,SEQUENCE(LEN(A1),,2,5),1))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM