I need to check a string for all (case sensitive) substrings which are palindromes between 2 and 7 characters with space being the separator (i.e. "aba abbbbba daba" returns "aba" and "abbbbba" but not "daba") in Javascript. This is my code.
var regex= /\b(\S?)(\S?)(\S)\S\3?\2?\1?\b/g
It works for tests I've thrown it to work so far, except for case matching. "abbA CdDc" is throwing up a match but I can't work out why since I haven't included the i flag. I'm assuming that something in my capture groups or backreferences is telling it to ignore case, but I can't work out what or how to fix it.