• + 1 comment

    Disappointed to see no answer using findall directly (I know why). Here is my solution with findall

    pat = r'^[!@#$%&\s]*[0-9A-Za-z]*[!@#$%&\s]*$|^[!@#$%&\s]*[0-9A-Za-z]+|[0-9A-Za-z]+[!@#$%&\s]*$|[0-9A-Za-z]+'
    decoded_script = re.findall(pat, script)
    print(' '.join(decoded_script))