Re.findall() & Re.finditer()

Sort by

recency

|

365 Discussions

|

  • + 0 comments
    import re
    
    pattern = r'(?<=[qwrtypsdfghjklzxcvbnmQWRTYPSDFGHJKLZXCVBNM])([aeiouAEIOU]{2,})(?=[qwrtypsdfghjklzxcvbnmQWRTYPSDFGHJKLZXCVBNM])'
    results = list(re.finditer(pattern, input()))
    print(*[x.group(1) for x in results] if results else [-1], sep="\n")
    
  • + 0 comments
    import re
    
    s = input()
    vowels = "aeiouAEIOU"
    consonants = "qwrtypsdfghjklzxcvbnmQWRTYPSDFGHJKLZXCVBNM"
    
    pattern = r'(?<=['+consonants+'])(['+vowels+']{2,})(?=['+consonants+'])'
    
    matches = re.findall(pattern, s)
    
    if matches:
        for match in matches:
            print(match)
    else:
        print(-1)
    
  • + 0 comments
    import re
    
    pattern = r'(?<=[^aeiouAEIOU])([aeiouAEIOU]{2,})(?=[^aeiouAEIOU])'
    
    s = input()
    
    matches = re.findall(pattern, s)
    
    if matches:
        for match in matches:
            print(match)
    else:
        print(-1)
    
  • + 0 comments

    Simple solution form my side..

    string = input()
    
    vowels = ['a','e','i','o','u']
    
    result = []
    word = ''
    for item in string:
        if( item.lower() in vowels):
            word = word +item
        else:
            if(len(word)>=2):
                result.append(word)
            word = ''
    
    if(len(result) == 0):
        print(-1)
    else:
        for words in result:
            print(words)
    
  • + 0 comments

    Here's my code:

    from re import findall, IGNORECASE
    print('\n'.join(findall(r'(?=[^aeiou]([aeiou]{2,})[^aeiou])', input(), IGNORECASE)) or -1)