Added regex for other elements, improved alternation by sorting and escaping.