Answers for "add space before and after string python"

0

add space before and after string python

using re adds white-space before and after the desired characters:

import re

pat = re.compile(r"([.()!])")
print (pat.sub(" \\1 ", string))
# hello .  .  .   ( world )  !
Posted by: Guest on March-20-2021

Code answers related to "add space before and after string python"

Python Answers by Framework

Browse Popular Code Answers by Language