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

44 Views Asked by At

I have this string : "397"

The special character has the code point : 1114111

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

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

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

Thanks

1

There are 1 best solutions below

0
Pvria Ansari On

you should try this:

"397".match(/.{2}/gu)