Using regular expression to divide two words and capture the first word

Using regular expression to divide two words and capture the first word

following part-of-speech tagged sentence: All/DT animals/NNS are/VBP equal/JJ ,/, but/CC some/DT animals/NNS are/VBP more/RBR equal/JJ than/IN others/NNS ./.

following part-of-speech tagged sentence: All/DT animals/NNS are/VBP equal/JJ ,/, but/CC some/DT animals/NNS are/VBP more/RBR equal/JJ than/IN others/NNS ./.

How to write a regular expression that matches only the words of each word/pos-tag in the sentence.

text="""All/DT animals/NNS are/VBP equal/JJ ,/, but/CC some/DT animals/NNS 
are/VBP more/RBR equal/JJ than/IN others/NNS ./."""
tokens=nltk.word_tokenize(text)
pattern="([A-Za-z]+)|[A-Za-z]"
print("Upper case words:")
for tok in tokens:
   if re.search(pattern, tok) is not None:
      print("'{}'".format(tok))


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top Python Development Companies | Hire Python Developers

After analyzing clients and market requirements, TopDevelopers has come up with the list of the best Python service providers. These top-rated Python developers are widely appreciated for their professionalism in handling diverse projects. When...

Python RegEx (Regular Expressions) Tutorial

Python RegEx (Regular Expressions) tutorial will help you in understanding how to use regular expressions in Python. You will get to learn different regular expression operations and syntaxes. Why we use Regular Expressions? What are Regular Expressions? Basic Regular Expressions operations. E-mail verification using Regular Expressions. Phone number verification using Regular Expressions. Web scraping using Regular Expressions

Python RegEx (Regular Expressions) Tutorial with Examples

Python RegEx (Regular Expressions) tutorial will help you in understanding how to use regular expressions in Python. You will get to learn different regular expression operations and syntaxes. Why we use Regular Expressions? What are Regular Expressions? Basic Regular Expressions operations. E-mail verification using Regular Expressions. Phone number verification using Regular Expressions. Web scraping using Regular Expressions