简体   繁体   中英

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. 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. 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. 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?

In excel sheet, with ExcelO365 you can use Sequence() formula with MID() function like-

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

在此处输入图像描述

For second one just make Start Number parameter of Sequence() formula to 2 like

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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