Given a word, check whether it is a simple English word, with these characteristics: Contains at least one vowel, Doesn’t contain three consecutive vowels or consonants, Vowels ‘e’ and ‘o’ can be repeated twice consecutively, but other vowels can’t. Can it be done using traditional regular expression?!!

the question what is the regular expressions that solve this problem
I'm new with regular expressions

6 Years
Discussion Span
Last Post by AhmedGhazey

You have three conditions (two of which are wrong, but that's okay) All of them are pretty amenable to regex, though I don't know what's meant by "traditional" - that could be a gotcha.

There are good regex tutorials available, read through one of them. If that doesn't work, read through a second. If you're still confused, you'll at least have some better questions when you're done, and you'll get better answers.


In trying not to answer the question jon already gave good enough hints.. post what you've done so far and you'll get the answers..

public boolean isCorrect(String word) {

        Pattern p = Pattern.compile("([bcdBCDfghFGHjklmnJKLMNpqrstPQRSTvwxyzVWXYZ]{3}|[aeiou]{3}|[a]{2}|[i]{2}|[u]{2})+");
        Matcher m = p.matcher(word);
        if (m.find()) {
            return false;
        return true;


Edited by Ezzaral: Added code tags. Please use them to format any code that you post.


sry I don't understand the question
really I search for any one give me hints so I didn't post any work because I don't understand .
Thanks thekashyap and jon.kiparsky

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.