def search(*patterns):
    """Decorate a function to be called when a pattern matches anywhere in a line.

    :param str patterns: one or more regular expression(s)

    Each argument is a regular expression which will trigger the function::

        @search('hello', 'here')
            # will trigger once on "hello you"
            # will trigger twice on "hello here"
            # will trigger once on "I'm right here!"

    This decorator can be used multiple times to add more search rules::

        @search('here')
        @search('hello')
            # will trigger once on "hello you"
            # will trigger twice on "hello here" (once per expression)
            # will trigger once on "I'm right here!"

    If the Sopel instance is in a channel, or sent a PRIVMSG, where a part
    of a string matching this expression is said, the function will execute.
    Note that captured groups here will be retrievable through the
    :class:`~sopel.trigger.Trigger` object later. The match will also contain
    the position of the first instance found.

    Inside the regular expression, some special directives can be used.
    ``$nick`` will be replaced with the nick of the bot and ``,`` or ``:``, and
    ``$nickname`` will be replaced with the nick of the bot::

        @search('$nickname')
            # will trigger once when the bot's nick is in a trigger

    .. versionadded:: 7.1

    .. note::

        The regex rule will match for the first instance only, starting from
        the left of the line, and the function will execute only once per
        regular expression.

        To match for each time an expression is found, use the :func:`find`
        decorator instead. To match only once from the start of the line,
        use the :func:`rule` decorator instead.

    """
    def add_attribute(function):
        function._sopel_callable = True
        if not hasattr(function, "search_rules"):
            function.search_rules = []
        for value in patterns:
            if value not in function.search_rules:
                function.search_rules.append(value)
        return function

    return add_attribute