Regex in a window-slide esq possible?

26 Views Asked by At

I am wondering if it is possible to use regex to split/replace a string and pad the matches with following n characters?

For example, my use case would be to parse strings in window-slide esque way:

with n = 3

"abcdef".split("..")

becomes

["abc", "bcd", "cde", "def"]

or in the case of replace,

"abcdef".replace("..")

becomes

"abcbcdcdedef"

Is there any way to implement this?

Thanks!

0

There are 0 best solutions below