from typing import Sequence
import re


def list_to_patt(lst: Sequence[str], name: str) -> str:
    """
    Create a regex pattern in string form capable of matching each element
    in a list.

    Beware of having empty string in lst!

    Arguments:
      lst: list of strings for which a regex pattern is to be determined.
      name: name to be given to the output group pattern.

    Returns:
      regex pattern in string form that can match each element in lst.
    """
    # longer strings need to be matched first
    lst = sorted(lst, key=len, reverse=True)
    patt = "|".join(re.escape(elem) for elem in lst)
    patt = f"(?P<{name}>{patt})"
    return patt