Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Tetravocalic: Find all words that include four consecutive vowels.
def Tetravocalic(i):
return(re.search("/\b.*[aeiou]+.*[aeiou]+.*[aeiou]+.*[aeiou]+{4}/\b",i)))
Tetravocalic("vajjekiohkkugh")
error: multiple repeat at position 42
Please let me know the meaning of the error and the correct code as well.
ex: Tetravocalic("vajjekiohkkugh apple ororaeeg")
Your regular expression is way too complex, you only need this :'[aeiou]{4}'.
Example code:
def has_four_consecutive_vowels(s):
return bool(re.search('[aeiou]{4}', s))
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 months ago.
Improve this question
I need help with python. How can I separate combine word into two words. At the first we don't know what kind of words could be? so we must enter a string at the input (v="") and then that word must be separate. For example we have "AMnidcrheaal" and in output will be "Andrea" and "Michal".
According to the output you gave, you want to separate odd and even indices words which can be done as follows
v="AMnidcrheaal"
even=""
odd=""
for i in range(len(v)):
if i%2==0:
even+=v[i]
else:
odd+=v[i]
print(odd)
print(even)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have column with this kind of data:
I want to count how many times valu occur in a row. It is a string, so I want to convert this '63,63,63,63,63,63,63,63,63,63,63' to this ['63','63','63'...].
I there any way to do this quickly?
Thanks
if given string is s
l=s.split(',')
l is the required list
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have a list of strings and I only want to keep the first 80% of text of each string. So, if a string has for example 100 words, I only want to keep the first 80 words. The split function is not suitable for this problem.
What function can I use, while iterating over the list, to achieve this?
Why isn't it?
sentence = "long string lots of words..."
parts = sentence.split()
newsentence = ' '.join(parts[:len(parts)*4//5])
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need to find a word "little" in a string but word in the string is not present as a whole.
For eg. input string="aalbeiedteetoolpue" or "lliittttllleee"
May be you can try this:
\b\w*l\w*i\w*t\w*t\w*l\w*e\w*\b
Demo
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have following python code:
import re
result = re.match('a.*b', 'aabab')
result.groups() # result is ()
len(result.groups()) # it's 0
result.group(0) # result is 'aabab'
I only know some basic regex, but I can not understand the groups and group. Could someone give some basic explanation about this.
and more, please give some explanation about Pattern and Matcher in python if possible.
Groups are used to capture specific parts of a regular expression. Your regex does not define any groups, therefore the group count is zero.
group(0) is a special case, and it contains the entire match.