I need Regex in Javascript to match repeatable alphabet.
I want to specify a duplicate letter in a string using a regular expression. As well as a split around them.
var str = "aabbcde"; str.split(/[az](?=$1)/g)
but it still returns a whole string. I want to split ["aabbcde"]. How to make a regular expression pattern match duplicate letters? What I tried is a match with one alphabet first and what follows from a match using (? = Regex. But this is not wokr. Any idea? Thanks a lot
My output result will be
var str = "aabbcde"; str.split(/[az](?=$1)/g) // output = ["aa", "bb", "c", "d", "e"]
user2671513
source share