This is the one I would use (in Python syntax):
word_with_a_and_b = re.compile(r"""
# Match word having both "a" and "b".
\b # Anchor to start of word.
(?=[^\Wa]*a) # Assert word contains an "a".
(?=[^\Wb]*b) # Assert word contains a "b".
\w+ # Match the word having both "a" and "b".
\b # Anchor to end of word.
""", re.VERBOSE | re.IGNORECASE)
source
share