Test, validate and match regular expressions
This regex extracts the root module or object name from a dotted Python expression, such as extracting `os` from `os.path.join`. It uses a negative lookbehind to ensure it only matches the beginning of the dotted path, avoiding chained attributes. This is particularly useful for static code analysis, identifying imports, or parsing object method calls in Python scripts.