Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to get each word in a string in python

# Python3 code to demonstrate
# to extract words from string
# using regex( findall() )
import re
 
# initializing string 
test_string = "Geeksforgeeks,    is best @# Computer Science Portal.!!!"
 
# printing original string
print ("The original string is : " +  test_string)
 
# using regex( findall() )
# to extract words from string
res = re.findall(r'w+', test_string)
 
# printing result
print ("The list of words is : " +  str(res))

#Output>>> [‘Geeksforgeeks’, ‘is’, ‘best’, ‘Computer’, ‘Science’, ‘Portal’]
Comment

PREVIOUS NEXT
Code Example
Python :: calculate iou of two rectangles 
Python :: if elif else ladder in python 
Python :: generate a random string with lowercase uppercase and numbers 
Python :: intersection_update() Function of sets in python 
Python :: flask env variable 
Python :: for loop for multiple things 
Python :: csrf is not detected using sendbeacon django 
Python :: page views count django 
Python :: getroot xml python 
Python :: Class based Django rest framework 
Python :: gensim word2vec loop keyed vector 
Python :: design patterns in python free download 
Python :: pandas merge keep one of column copy 
Python :: Uploading small amounts of data into memory 
Python :: generate a hash/secret python 
Python :: database access layer django 
Python :: manim replacement transform 
Python :: giving activation in dense layer keras 
Python :: python created nested directory 
Python :: beautifulsoup documentation 
Python :: how a 16 mp camera looks like 
Python :: repeat printing rows excel using python whenever i run the script 
Python :: download face_cascade.detectMultiScale 
Python :: python - columns that contain the lengh of a string 
Python :: how to draw play area for a game in python turtle 
Python :: flip a coin with array in python 
Python :: online image to python text converter 
Python :: To install the C++ and Python Messaging APIs: 
Python :: Python Class Without Getters and Setters 
Python :: Convert Time object to String in python 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =