I need to check if a string is formed by the continuous pattern of alternating vowels and consonants and vice versa is a valid pattern string or not..,here is my code
import re
s1="japan"
s2="iran"
s3="brazil"
pattern=re.compile(r'^(([aeiou][^aeiou])+|([^aeiou][aeiou])+)$')
matching1=re.match(pattern,s1)
matching2=re.match(pattern,s2)
matching3=re.match(pattern,s3)
if(matching1):
print(f"{s1} follows a valid pattern")
else:
print(f"{s1} does not follows a valid pattern")
so, what i am trying to do is, i need to return string s1 as a valid pattern string,because Jis a consonant , A is a vowel , P is a consonant,A is a vowel ,N is a consonant
and similarly; s2 as a valid pattern string
and s3 as an invalid pattern string.
but what i got is, S1 and S3 as an invalid pattern string
and s2 as a valid pattern string and that too failed if i put another vowel lets say A and make it as irana