How to find the occurrences of any word with more than two vowels in a file using regex

0 votes

I'm having trouble figuring out how to find all words that have 2 or more vowels in them. So far this is what I have but when i run it, it don't give me any output. I appreciate the help.

import re

def main():

in_f = open("jobs-061505.txt", "r")
read =
for word in read:
    re.findall(r"\b[aAeEiIoOuU]*", read)
    in_f = open("twoVoweledWordList.txt", "w")

print (word)
Nov 24, 2020 in Python by anonymous
• 8,880 points

1 answer to this question.

0 votes
for word in read:  <--- iterating over chars in "read"!
    re.findall(r"\b[aAeEiIoOuU]*", read)  <-- using read again, discarding result

your iteration and pattern usage do not align. Plus, you don't use the result.

Consider processing the file line by line etc.

twovowels=re.compile(r".*[aeiou].*[aeiou].*", re.I)
nonword=re.compile(r"\W+", re.U)
file = open("filename")
for line in file:
    for word in nonword.split(line):
        if twovowels.match(word): print word
answered Nov 24, 2020 by Gitika
• 65,930 points

Related Questions In Python

0 votes
1 answer

How to find the value of a row in a csv file in python?

If you want to find the value ...READ MORE

answered May 20, 2019 in Python by Sanam
0 votes
1 answer

How to find the value of a row in a csv file in python and print column and row of that value ?

Hello @Khanhh , Use panda to find the value of ...READ MORE

answered Oct 15, 2020 in Python by Niroj
• 82,780 points
–1 vote
2 answers

How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

answered Mar 29, 2019 in Python by rajesh
• 1,230 points
0 votes
1 answer

How to find the index of a particular value in a dataframe?

First, use the dataframe to match the ...READ MORE

answered Apr 8, 2019 in Python by Esha
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,254 views
0 votes
0 answers
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
0 votes
4 answers

how to sort a list of numbers without using built-in functions like min, max or any other function?

Yes it is possible. You can refer ...READ MORE

answered Jun 27, 2019 in Python by Arvind
• 3,000 points