Using regular expression for fetching multiple keywords using python 3.4

Maxxie

I am using python 3.4 in windows 7. I have excel sheet in which data is present in every cell. The data is of different kinds .Two examples :- "Qwert A_B_C_1 uiop" and "Qwert A_X_Y_Z uiop"

To sum up i have to extract keywords which are written in CAPS where just after the first word an underscore is present. The extracting should stop once a whitespace is encountered

I have tried something like this but

x =  "QWERT A_B_C_1 UIOP"
se = re.findall("[A-Z]+_[A-Z]+_[A-Z]+_[0-9A-Z]+",x)

But it is not working with different types of keywords.

vks
[A-Z]+(?:_[A-Z]+)*_[A-Z0-9]+

You can use this to capture variable _[A-Z] in between.See demo

import re
p = re.compile(r'[A-Z]+(?:_[A-Z]+)*_[A-Z0-9]+')
test_str = "QWERT A_B_C_1 UIOP\nQwert A_X_Y_Z uiop"

re.findall(p, test_str)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Regular Expression using Python

From Dev

Regular Expression using Python

From Dev

Python regular expression using the OR operator

From Dev

Python regular expression using the OR operator

From Dev

How to match multiple strings using regular expression?

From Dev

Turning (,,,text,,4,text,3,,) into (text,4,text,3) using regular expression

From Dev

Using regular expression in neo4j

From Dev

find words of length 4 using regular expression

From Dev

find words of length 4 using regular expression

From Dev

Regular expression replace using Sublime Text 3

From Dev

Invalid syntax using regular expression in python 3.4

From Dev

Python using Regular Expression to convert a string

From Dev

Splitting a string with brackets using regular expression in python

From Dev

Parsing query string using regular expression in python

From Dev

Split on roman numbers using regular expression in python

From Dev

Extract particular value using regular expression in Python

From Dev

python Using Regular Expression to find letters in a string

From Dev

replace a substring in python using regular expression

From Dev

Invalid syntax using regular expression in python 3.4

From Dev

Python using regular expression to pick texts

From Dev

Extract particular value using regular expression in Python

From Dev

Replace string by matching using regular expression python

From Dev

Iterating through dataframe using regular expression python

From Dev

IP match using regular expression in python 2.7

From Dev

Parse a substring in Python using regular expression

From Dev

Regular expressions, using an expression in Python with a space involved

From Dev

Using a list as an argument for a regular expression in python

From Dev

Regular expression for fetching variables

From Dev

Using a variable in a regular expression

Related Related

  1. 1

    Regular Expression using Python

  2. 2

    Regular Expression using Python

  3. 3

    Python regular expression using the OR operator

  4. 4

    Python regular expression using the OR operator

  5. 5

    How to match multiple strings using regular expression?

  6. 6

    Turning (,,,text,,4,text,3,,) into (text,4,text,3) using regular expression

  7. 7

    Using regular expression in neo4j

  8. 8

    find words of length 4 using regular expression

  9. 9

    find words of length 4 using regular expression

  10. 10

    Regular expression replace using Sublime Text 3

  11. 11

    Invalid syntax using regular expression in python 3.4

  12. 12

    Python using Regular Expression to convert a string

  13. 13

    Splitting a string with brackets using regular expression in python

  14. 14

    Parsing query string using regular expression in python

  15. 15

    Split on roman numbers using regular expression in python

  16. 16

    Extract particular value using regular expression in Python

  17. 17

    python Using Regular Expression to find letters in a string

  18. 18

    replace a substring in python using regular expression

  19. 19

    Invalid syntax using regular expression in python 3.4

  20. 20

    Python using regular expression to pick texts

  21. 21

    Extract particular value using regular expression in Python

  22. 22

    Replace string by matching using regular expression python

  23. 23

    Iterating through dataframe using regular expression python

  24. 24

    IP match using regular expression in python 2.7

  25. 25

    Parse a substring in Python using regular expression

  26. 26

    Regular expressions, using an expression in Python with a space involved

  27. 27

    Using a list as an argument for a regular expression in python

  28. 28

    Regular expression for fetching variables

  29. 29

    Using a variable in a regular expression

HotTag

Archive