I have MMYY pattern ( credit card expiry)
I need to analyze each section (01 and 14) : So I tried :
'0114'.split(/\d{2}/i) // ["", "", ""]
It actually see 2 digits as a separators and hence I get nothing.
However , I've managed to do it with :
'0114'.match(/\d{2}/ig) //["01", "14"]
But I wonder about split.
Can I do it also with split ?
For example:
"1234".split(/(?=..$)/) => ["12", "34"]
A generic solution for strings of arbitrary length appears to be impossible, the best we can get is something like:
str.split(str.length & 1 ? /(?=(?:..)*.$)/ : /(?=(?:..)+$)/)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With