Horje
string without space pythonm Code Example
string without space pythonm
import re

string = '  Hello  World   From Pankaj \t\n\r\tHi There  '

print('Remove all spaces using RegEx:\n', re.sub(r"\s+", "", string), sep='')  # \s matches all white spaces
print()

print('Remove leading spaces using RegEx:\n', re.sub(r"^\s+", "", string), sep='')  # ^ matches start
print()

print('Remove trailing spaces using RegEx:\n', re.sub(r"\s+$", "", string), sep='')  # $ matches end
print()

print('Remove leading and trailing spaces using RegEx:\n', re.sub(r"^\s+|\s+$", "", string), sep='')  # | for OR condition




Python

Related
progress bar in python Code Example progress bar in python Code Example
flask mongoengine configuration Code Example flask mongoengine configuration Code Example
flask mongoengine getting started Code Example flask mongoengine getting started Code Example
how to get csv file first row first column value in python Code Example how to get csv file first row first column value in python Code Example
how to make a grid in python Code Example how to make a grid in python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9