Answers for "how to remove text from string python"

15

take off character in python string

s = 'abc12321cba'

print(s.replace('a', ''))
Posted by: Guest on August-10-2020
1

python remove letters from string

string = "abc123"
# Method 1
''.join(char for char in string if char.isdigit())

#Method 2
import re
re.sub("[^0-9]", "", string)
Posted by: Guest on December-03-2020
11

python remove string from string

s = 'ab12abc34ba'
print(s.replace('ab', ''))
Posted by: Guest on September-12-2020
19

remove from string python

"Str*ing With Chars I! don't want".replace('!','').replace('*','')
Posted by: Guest on May-13-2020
1

remove word from string in python

#you can use replace function to remove specific word.
message = 'you can use replace function'
message = message.replace('function', '')
print(message)
Posted by: Guest on July-04-2021
0

python trim certain characters from string

string = '  xoxo love xoxo   '

# Leading and trailing whitespaces are removed
print(string.strip())

# All <whitespace>,x,o,e characters in the left
# and right of string are removed
print(string.strip(' xoe'))

#
Posted by: Guest on December-15-2020

Code answers related to "how to remove text from string python"

Python Answers by Framework

Browse Popular Code Answers by Language