Fix extraction of language names for language options (#1127)

At least in some implementations, std::regex does not treat $ and ^ as the
beginning or end of a line but as the beginning or end of the whole string.