mbourd
mbourd

Reputation: 55

How to chunk a string containing characters with high code point?

I have this string : "3􏿿97"

The special character has the code point : 1114111

When I chunk the string : "3􏿿97".match(/.{2}/g)

I have this result : ['3\uDBFF', '\uDFFF9']

But I want this result : ['3􏿿', '97']

Thanks

Upvotes: 1

Views: 50

Answers (1)

Pvria Ansari
Pvria Ansari

Reputation: 456

you should try this:

"3􏿿97".match(/.{2}/gu)

Upvotes: 1

Related Questions