\$ # Our '$' prefix ( # Capture into $1 (?: \w+ # Plain word. | \( \w+ \) # A word with parentheses around it. ) )