import re


def check_exact_match(line, expected_line):
    """
    Uses regular expressions to find an exact (not partial) match for 'expected_line' in 'line', i.e.
    in the example below it matches 'foo' and succeeds:
        line value: '66118.999958 - INFO - [MainThread] - ly_test_tools.o3de.asset_processor - foo'
        expected_line: 'foo'

    :param line: The log line string to search,
        i.e. '9189.9998188 - INFO - [MainThread] - example.tests.test_system_example - Log Monitoring test 1'
    :param expected_line: The exact string to match when searching the line param,
        i.e. 'Log Monitoring test 1'
    :return: An exact match for the string if one is found, None otherwise.
    """

    # Look for either start of line or whitespace, then the expected_line, then either end of the line or whitespace.
    # This way we don't partial match inside of a string.  So for example, 'foo' matches 'foo bar' but not 'foobar'
    regex_pattern = re.compile("(^|\\s){}($|\\s)".format(re.escape(expected_line)), re.UNICODE)
    if regex_pattern.search(line) is not None:
        return expected_line

    return None