#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)([\w]+)[ \t]+=[ \t](Solver[ \t]*\(([\d.]+)[ \t]*,[ \t]*([\d.]+)[ \t]*,[ \t]*([\d.]+)[ \t]*\))\n\r?demo[ \t]*\(\1\.b[ \t]*,[ \t]*\1\.a[ \t]*,[ \t]*\1\.c[ \t]*\)"
Local $sString = "import math" & @CRLF & _
"" & @CRLF & _
"class Solver(object):" & @CRLF & _
" def __init__(self, a, b, c):" & @CRLF & _
" self.a = a" & @CRLF & _
" self.b = b" & @CRLF & _
" self.c = c" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"def demo(b, a, c):" & @CRLF & _
" d = b ** 2 - 4 * a * c" & @CRLF & _
" if d >= 0:" & @CRLF & _
" disc = math.sqrt(d)" & @CRLF & _
" root1 = (- b + disc) / (2 * a)" & @CRLF & _
" root2 = (- b - disc) / (2 * a)" & @CRLF & _
" print(root1, root2)" & @CRLF & _
" return root1, root2" & @CRLF & _
" else:" & @CRLF & _
" raise Exception" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"s = Solver(2, 123, 0.025)" & @CRLF & _
"demo(s.b, s.a, s.c)"
Local $sSubst = "$2\.demo()"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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