def ValuesListToRegexp(valList, width):
    """This transforms a range of integer values into a regular expression
    matching them in a binary buffer.
    Width is typically one, two or four, but can be anything."""
    maxVals = max(valList)
    if maxVals < 256:
        subRegEx = "".join(r"\x%02x" % val for val in valList)
        pad = r"\x00" * (width - 1)
        # Maybe the values are contiguous but we do not care.
        return "[" + subRegEx + "]" + pad

    # For the moment, the other cases are not treated.
    raise Exception("Not implemented now")