#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)[\t:]*(from (.*?)[ ]*|)import (.*?)(| as (.*?))[\n]"
Local $sString = "import os" & @CRLF & _
"import os as test" & @CRLF & _
"from RegistryController import RegistryController" & @CRLF & _
"from ui.windows.lists import ListCtrl, DynamicListCtrl" & @CRLF & _
"from main.core import Exceptions" & @CRLF & _
"from Queue import Queue" & @CRLF & _
"from main.core.MessageQueue import Queue as MessageQueue" & @CRLF & _
"from os import test as test" & @CRLF & _
"for i in range(50):import os" & @CRLF & _
" import os" & @CRLF & _
" for i in range(50):" & @CRLF & _
" import os" & @CRLF & _
" print("We are importing this new, import ajid.")"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm