import re


def process_query(s):
    """
    Converts the user's search string into something suitable for passing to
    to_tsquery.
    """
    # noqa Thanks https://www.fusionbox.com/blog/detail/partial-word-search-with-postgres-full-text-search-in-django/632/
    query = re.sub(r"[^-+@\w]+", " ", s).strip()
    if query:
        query = re.sub(r"\s+", " & ", query)
        # Support prefix search on the last word. A tsquery of 'toda:*' will
        # match against any words that start with 'toda', which is good for
        # search-as-you-type.
        query += ":*"
    return query