import re


def _path_regex(path_parts, path_constraints):
    """
    Construct the regular expression to match a particular route path.

    :param pvector path_parts: ``path_parts`` component of a parsed route.
    :param pmap path_constraints: ``path_constrants`` component of a parsed
    route.
    :return: Compiled regular expression.
    """
    return re.compile(
        u'/' +
        u'/'.join(path_constraints.get(p, re.escape(p)) for p in path_parts))