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
People also ask

How to remove stop words from text in nltk?
Removing stop words with NLTK. The following program removes stop words from a piece of text: from nltk.corpus import stopwords. from nltk.tokenize import word_tokenize. example_sent = "This is a sample sentence, showing off the stop words filtration.". stop_words = set(stopwords.words('english'))
🌐
convertf.com
convertf.com › nltk-remove-numbers
Nltk remove numbers
Do you need nltk to remove punctuation in python?
You do not really need NLTK to remove punctuation. You can remove it with simple python. For strings: and then use this string in your tokenizer. P.S. string module have some other sets of elements that can be removed (like digits).
🌐
convertf.com
convertf.com › nltk-remove-numbers
Nltk remove numbers
How to get a word token in nltk?
With the help of nltk.tokenize.word_tokenize () method, we are able to extract the tokens from string of characters by using tokenize.word_tokenize () method. It actually returns the syllables from a single word. A single word can contain one or two syllables. Syntax : tokenize.word_tokenize ()
🌐
convertf.com
convertf.com › nltk-remove-numbers
Nltk remove numbers
🌐
Convertf
convertf.com › nltk-remove-numbers
Nltk remove numbers
NLTK provides a list of commonly agreed upon stop words for a variety of languages, such as English. And finally dealing with numbers! You can convert all numbers to the same token, have one token for each number of ... 2 hours ago Remove all numbers from string using regex.
🌐
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 re.sub(pattern, replace, string) takes the string as input and returns the string by replacing the non-overlapping occurrences of the pattern string (described as a regular expression) with the replace value in the string.
🌐
YouTube
youtube.com › pavan kumar tech passions
Mastering NLP: Removing Numbers from Text in Python regular expression | How to remove num from text - YouTube
I hope you like this videodo hit likes.And do subscribe to my channelThank you so much for watchinggod bless you all.lots of ❤️❤️❤️❤️❤️*********************...
Published   March 21, 2023
Views   59
🌐
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 - A third option is to use the sub() function of Python’s re (Regular expression) module.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python-remove-all-digits-from-a-list-of-strings
Python | Remove all digits from a list of strings - GeeksforGeeks
December 26, 2024 - Regular Expressions efficiently remove digits from strings by matching and replacing them. This uses the re.sub() function to substitute digits (\d) with an empty string.
🌐
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 - In this, we perform task of split() to get all words, getting index of K number using index() and list compre ... In Python, removing a substring from a string can be achieved through various methods such as using replace() function, slicing, or regular expressions.
🌐
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
🌐
Medium
medium.com › @priyankads › common-regular-expressions-for-text-cleaning-in-python-5a13b832d340
Common Regular Expressions for Text Cleaning in Python | by Priyanka | Medium
November 18, 2022 - The regular expression package “re” can be used to perform several operations such as string substitutions, searches, and manipulations.
🌐
Python
mail.python.org › pipermail › tutor › 2005-August › 040908.html
[Tutor] Remove a number from a string
August 23, 2005 - With str.lstrip(): >>> '347 liverpool street'.lstrip('0123456789') ' liverpool street' or, if you want to strip the space as well: >>> '347 liverpool street'.lstrip('0123456789 ') 'liverpool street' With a regular expression: >>> import re >>> re.sub('^[0-9]+', '', '347 liverpool street') ' liverpool street' or >>> re.sub('^[0-9 ]+', '', '347 liverpool street') 'liverpool street' If you are doing this a lot my guess is that a compiled re will be faster but that's just a guess...
🌐
TutorialsPoint
tutorialspoint.com › python-program-to-remove-numbers-with-repeating-digits
Python Program to Remove numbers with repeating digits
In this article, we will learn how to remove numbers with repeating digits in python. Methods Used The following are the various methods to accomplish this task − Using list comprehension and set() function Using re module Using the Counter() functi
🌐
H2K Infosys
h2kinfosys.com › blog › nltk regular expressions
NLTK Regular Expressions | H2K Infosys Blog
September 11, 2022 - To have a rounded understanding of how to effectively apply the Regexp module, let’s discuss some of the most useful functions. re.split(pattern, string, [maxsplit=0]): This function splits a list of strings according to some defined pattern.
🌐
CodeSignal
codesignal.com › learn › courses › foundations-of-nlp-data-processing-2 › lessons › text-cleaning-and-normalization-in-nlp
Text Cleaning and Normalization in NLP
In this step, we will use regular ... characters, numbers, and punctuation from the text. The re.sub function from the re library is a powerful tool for this task. It allows us to search for specific patterns in the text and replace them with a desired string, which in this ...
🌐
Analytics Vidhya
analyticsvidhya.com › home › a quick guide to text cleaning using the nltk library
A Quick Guide to Text Cleaning Using the nltk Library
October 21, 2024 - text = "Hello! How are you!! I'm very excited that you're going for a trip to Europe!! Yayy!" re.sub("[^-9A-Za-z ]", "" , text) Punctuations can also be removed by using a package from the string library.
🌐
Netlify
michael-fuchs-python.netlify.app › 2021 › 05 › 22 › nlp-text-pre-processing-i-text-cleaning
NLP - Text Pre-Processing I (Text Cleaning) - Michael Fuchs Python
import pandas as pd import numpy as np import pickle as pk import warnings warnings.filterwarnings("ignore") from bs4 import BeautifulSoup import unicodedata import re from nltk.tokenize import word_tokenize from nltk.tokenize import sent_tokenize from nltk.corpus import stopwords from nltk.corpus import wordnet from nltk import pos_tag from nltk import ne_chunk from nltk.stem.porter import PorterStemmer from nltk.stem.wordnet import WordNetLemmatizer from nltk.probability import FreqDist import matplotlib.pyplot as plt from wordcloud import WordCloud · df = pd.read_csv('Amazon_Unlocked_Mobile_small.csv') df.head() However, we will only work with the following part of the data set: ... To be on the safe side, I convert the reviews as strings to be able to work with them correctly.
🌐
Netlify
michael-fuchs-python.netlify.app › 2021 › 06 › 05 › nlp-text-pre-processing-iv-single-character-removal
NLP - Text Pre-Processing IV (Single Character Removal) - Michael Fuchs Python
For this publication the processed ... Example String. You can download both files from my “GitHub Repository”. import pandas as pd import numpy as np import pickle as pk import warnings warnings.filterwarnings("ignore") from bs4 import BeautifulSoup import unicodedata import re from nltk.tokenize import ...
🌐
HCL GUVI
studytonight.com › python-howtos › remove-numbers-from-string-in-python
HCL GUVI | Learn to code in your native language
Zen Classes are HCL GUVI's most refined and flagship product—live, expert-led tech programs for beginners and pros.