RemoteMojo / regex.py
SoUmNerd's picture
Upload 3 files
4ec23ab
raw
history blame contribute delete
456 Bytes
import re
def find_imports(code):
pattern = r'Python\.import_module\("([^"]*)"\)'
matches = re.findall(pattern, code)
return matches
if __name__ == "__main__":
code = '''
from python import Python
Python.import_module("numpy")
Python.import_module("pandas")
Python.import_module("matplotlib")
def main():
print("hello world")
'''
print(find_imports(code)) # Output: ['numpy', 'pandas', 'matplotlib']