Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python re.subn()

# Program to remove all whitespaces
import re

# multiline string
string = 'abc 12
de 23 
 f45 6'

# matches all whitespace characters
pattern = 's+'

# empty string
replace = ''

new_string = re.subn(pattern, replace, string) 
print(new_string)

# Output: ('abc12de23f456', 4)
Source by www.kite.com #
 
PREVIOUS NEXT
Tagged: #Python
ADD COMMENT
Topic
Name
5+9 =