Method : Using regex() + string.punctuation
This method also used regular expressions, but string function of getting all the punctuations is used to ignore all the punctuation marks and get the filtered result string.
# Python3 code to demonstrate
# to extract words from string
# using regex() + string.punctuation
import re
import string
# initializing string
test_string = "Geeksforgeeks, is best @# Computer Science Portal.!!!"
# printing original string
print ("The original string is : " + test_string)
# using regex() + string.punctuation
# to extract words from string
res = re.sub('['+string.punctuation+']', '', test_string).split()
# printing result
print ("The list of words is : " + str(res))
Output:
The original string is : Geeksforgeeks, is best @# Computer Science Portal.!!!
The list of words is : [‘Geeksforgeeks’, ‘is’, ‘best’, ‘Computer’, ‘Science’, ‘Portal’]