开发者

how to split into character group? [duplicate]

开发者 https://www.devze.com 2023-02-25 03:10 出处:网络
This question already has answers here: Split large string in n-size chunks in JavaScript (23 answers) Closed 9 years ago.
This question already has answers here: Split large string in n-size chunks in JavaScript (23 answers) Closed 9 years ago.

I want to split string

"abcde开发者_StackOverflow中文版fgh"

to

"ab","cd","ef","gh"

using javascript split()

"abcdefgh".split(???)

Can you please help ?


Instead of split, try match:

var text = "abcdefgh";
print(text.match(/../g));

prints:

ab,cd,ef,gh

as you can see on Ideone.

0

精彩评论

暂无评论...
验证码 换一张
取 消