Yes, you can use a regular expression for this:

import re
output = re.sub(r'\d+', '', '123hello 456world')
print output  # 'hello world'
Answer from Martin Konecny on Stack Overflow
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python string remove numbers
Python String Remove Numbers - Spark By {Examples}
May 21, 2024 - How to remove numbers from the string in Python? You can remove numeric digits/numbers from a given string in Python using many ways, for example, by
🌐
GeeksforGeeks
geeksforgeeks.org › python-ways-to-remove-numeric-digits-from-given-string
Python | Ways to remove numeric digits from given string - GeeksforGeeks
December 30, 2024 - For example we are given a string s=""abc123def456gh789" we need to extract all the numbers from the string so the output for the given string will become "123456789" In this article we will show different ways to extract digits from a string in Py · 2 min read Python Program for Remove leading zeros from a Number given as a string
🌐
YouTube
youtube.com › watch
How to Remove/Strip Numbers from a String in Python TUTORIAL (Common Python Interview Question) - YouTube
Python tutorial on how to remove numbers/integers/digits from a string.This is a common python interview question.Solution:'.join([i for i in x if not i.isdi...
Published   August 4, 2019
🌐
Delft Stack
delftstack.com › home › howto › python › remove numbers from string python
How to Remove Numbers From String in Python | Delft Stack
February 2, 2024 - The below example code demonstrates how to use the string.join() method to remove the numbers from the string in Python.
🌐
Linux Hint
linuxhint.com › remove-number-string-python
Linux Hint – Linux Hint
November 22, 2022 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
CodeFatherTech
codefather.tech › home › blog › 4 ways to remove numbers from string in python
4 Ways to Remove Numbers From String in Python - CodeFatherTech
December 8, 2024 - To remove numbers from a string in Python you can use different techniques. The first option is to use a for loop that goes through every character in the string and creates a new string made of characters that are not numbers. You can achieve the same result using the string join() method ...
Find elsewhere
🌐
Python Guides
pythonguides.com › remove-numbers-from-strings-in-python
How To Remove Numbers From Strings In Python?
March 19, 2025 - Python provides several ways to remove numeric digits from a given string, which we’ll cover in detail with examples. The re.sub() function from the re module is used to substitute parts of a string that match a given regular expression pattern with a specified replacement.
🌐
Replit
replit.com › home › discover › how to remove numbers from a string in python
How to remove numbers from a string in Python | Replit
April 13, 2026 - For truly international text, you'll need the unicodedata module when working with Unicode in Python. It provides a more powerful way to classify characters from any language. The unicodedata.category() function returns a character's official Unicode category. All numeric types—including decimal digits, letter-like numbers, and other numerals—belong to categories that start with 'N'. This makes checking .startswith('N') a reliable way to identify and remove any number. ... text = "Hello123World456" * 1000 # Large string import time start = time.time() result = ''.join(char for char in text if not char.isdigit()) end = time.time() print(f"Processed {len(text)} characters in {end - start:.6f} seconds")
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python extract numbers from string
Python Extract Numbers From String - Spark By {Examples}
May 21, 2024 - To extract numbers(both integers and floating-point numbers) from a string in Python, you can use regular expressions from the re module or use a simple loop to iterate through the characters in the string and identify numeric characters.
🌐
Built In
builtin.com › software-engineering-perspectives › python-remove-character-from-string
How to Remove Characters From a String in Python | Built In
In this article, I’ll explain how to remove different characters from a string in Python. Remove specific characters from the string. Remove all characters except alphabets from a string. Remove all characters except the alphabets and the numbers from a string.
Top answer
1 of 2
35

You can remove all digits, dots, dashes and spaces from the start using str.lstrip():

string1.lstrip('0123456789.- ')

The argument to str.strip() is treated as a set, e.g. any character at the start of the string that is a member of that set is removed until the string no longer starts with such characters.

Demo:

>>> samples = """\
... 123.123.This is a string some other numbers
... 1. This is a string some numbers
... 12-3-12.This is a string 123
... 123-12This is a string 1234
... """.splitlines()
>>> for sample in samples:
...     print 'From: {!r}\nTo:   {!r}\n'.format(
...         sample, sample.lstrip('0123456789.- '))
...
From: '123.123.This is a string some other numbers'
To:   'This is a string some other numbers'

From: '1. This is a string some numbers'
To:   'This is a string some numbers'

From: '12-3-12.This is a string 123'
To:   'This is a string 123'

From: '123-12This is a string 1234'
To:   'This is a string 1234'
2 of 2
1

This is almost the same as @MartijnPieters' answer but we could use constants from string module if there are a lot of punctuation and whitespace characters to strip on top of digits:

import string
nonalpha = string.digits + string.punctuation + string.whitespace
out = some_string.lstrip(nonalpha)

So for the given sample:

for sample in [string1, string2, string3, string4]:
    print('From: {!r}\nTo:   {!r}\n'.format(sample, sample.lstrip(nonalpha)))

Output:

From: '123.123.This is a string some other numbers'
To:   'This is a string some other numbers'

From: '1. This is a string some numbers'
To:   'This is a string some numbers'

From: '12-3-12.This is a string 123'
To:   'This is a string 123'

From: '123-12This is a string 1234'
To:   'This is a string 1234'
🌐
W3Schools
w3schools.com › python › ref_string_strip.asp
Python String strip() Method
Remove List Duplicates Reverse ... Plan Python Interview Q&A Python Bootcamp Python Training ... The strip() method removes any leading, and trailing whitespaces....
🌐
YouTube
youtube.com › watch
Remove Numbers From Strings - YouTube
This video shows how to take multiple elements, remove numbers from each text, trim those strings, and confirm them. cy.get('#fruit li') // jQuery Element[] ...
Published   July 20, 2023