How to remove special symbols /#$%^&*@0123456789 only if they are separated from each other by characters or symbols not in the list. For example:
H8e%&l6&%l@8095o a@/9^65$n228d w%e60$$#&9l3@/c6o5m3e --> Hello and welcome . #$%#^ --> . #$%#^ ,. a3%2%1/3$s*0. d8^! -->,. as. d! I1^/0^^@9t #$%% i/@4#s 11P17/9$M 5^&* a^$45$5$0n&##^4d 6^&&* I $%^$%^ a8@@94%3*m t3120i36&^1r2&^##0e&^d ---> It #$%% is 11PM 5^&* and 6^&&* I $%^$%^ am tired I know that simple string.replace will not work here. I tried something like this but it didn't work either:
def _correct_message(message): f = re.match(r'[a-zA-Z][/#$%^&*@0123456789][a-zA-Z]', message) if f is not None: message = re.sub('[/#$%^&*@0123456789]', '', message)