Reverse a string in Python but dont reverse alphanumerics
Question: I want to reveres a string but not alphanumeric characters and spaces in it.
How we can achieve it?

    
    
    input : "This is Testing! The email-id is testing@my.com"
    output : "sihT si gnitseT! ehT di-liame si gnitset@ym.moc"
    

how can I achieve it without re?


Answer: Through `re.sub`.

    
    
    >>> import re
    >>> s = "This is Testing! The email is testing@my.com"
    >>> re.sub(r'\w+', lambda m: m.group()[::-1], s)
    'sihT si gnitseT! ehT liame si gnitset@ym.moc'
    

We all know that `\w+` matches one or more word characters. And note that we
also use an anonymous function as second parameter in the `re.sub` function
which in-turn helps to do string operations on the matched characters.

