#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(def*\W(\w+)([\w\W]*?))(?=(def)|$)"
Local $sString = "def alchol_effect(self, player):" & @CRLF & _
" pygame.transform.rotate(player.game.window, 360)" & @CRLF & _
"" & @CRLF & _
"def hope_effect(self, player): " & @CRLF & _
" player.game.window.get_rect().move(0, 5)" & @CRLF & _
" time.sleep(0.25)" & @CRLF & _
" player.game.window.get_rect().move(0, -5)" & @CRLF & _
"" & @CRLF & _
"def mysterious_effect(self, player):" & @CRLF & _
" fun = os.path.join("data", "fun") " & @CRLF & _
" temmie = get_image(os.path.join(fun, "temmie.png"))" & @CRLF & _
" temmie_sound = pygame.mixer.Sound(os.path.join(fun, "temmie.ogg"))" & @CRLF & _
" for sprite in player.game.sprites.sprites:" & @CRLF & _
" sprite.image = temmie" & @CRLF & _
" self.window.blit(temmie)" & @CRLF & _
" pygame.transform.rotate(player.game.window, 360*4000)"
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