Use
\(([^()]*\bcm\b[^()]*)\)
See proof
Explanation
-------------------------------------------------------------------------------- \( '('-------------------------------------------------------------------------------- ( group and capture to \1:-------------------------------------------------------------------------------- [^()]* any character except: '(', ')' (0 or more times (matching the most amount possible))-------------------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char-------------------------------------------------------------------------------- cm 'cm'-------------------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char-------------------------------------------------------------------------------- [^()]* any character except: '(', ')' (0 or more times (matching the most amount possible))-------------------------------------------------------------------------------- ) end of \1-------------------------------------------------------------------------------- \) ')'