Design an algorithm to identify and extract substrings that match a complex pattern under specific character constraints.