from pathlib import Path


def preprocess_path(path):
    """Parse a string with path to Path instance."""
    parts = path.split('.')
    try:
        path_str = '.'.join(parts[:-1] + [parts[-1].rstrip(' /').split()[0]])
    except IndexError:
        return Path(path)
    path_str = path_str.strip(' \t\n\'"').replace('\\', '/')
    return Path(path_str)