import re
regex = re.compile(r"(?<=\W)Set(Scale|Blend|Alpha|Rotation|Color)\s*(\(?.+(?:\;|$))", flags=re.MULTILINE)
test_str = (" SetScale 1,1;\n"
" SetBlend alphaBLEND;\n"
" SetAlpha 1;\n"
" SetRotation 0;\n"
" SetColor 255,255,255;\n\n"
" //SetColor 228,33,0\n"
" SetColor s.rgb[0],s.rgb[1],s.rgb[2];\n"
"SetScale b.MorphNow*2,b.MorphNow*2;\n"
"SetAlpha map(b.HP[0],0,b.HP[1],0,1);\n"
"SetAlpha - float(n) / Fade1")
subst = "Set$1 $2"
result = regex.sub(subst, test_str)
if result:
print(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 Python, please visit: https://docs.python.org/3/library/re.html