Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

regular expression to remove space python

r = re.compile(r"^s+", re.MULTILINE)
r.sub("", "a
 b
 c") # "a
b
c"

# or without compiling (only possible for Python 2.7+ because the flags option
# didn't exist in earlier versions of re.sub)

re.sub(r"^s+", "", "a
 b
 c", flags = re.MULTILINE)

# but mind that s includes newlines:
r.sub("", "a



 b
 c") # "a
b
c"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #regular #expression #remove #space #python
ADD COMMENT
Topic
Name
4+5 =