I have the following strings
1. !abc.com
2. abc.com!
3. Hey there this is .abc.com!. This is amazing
I am trying to find a way such that I can identify special characters before or after the end of the URL in the string and add in a space only if the special character is at the beginning or end of the string, e.g.
!abc.com -> ! abc.com
abc.com! -> abc.com !
Hey there this is .abc.com!. This is amazing -> Hey there this is . abc.com !.This is amazing
What would be a good way to handle this scenario?
I tried the following regex: re.match('^.*$',w)
. But this seems very generic. Any advice or suggestion would be greatly appreciated.