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

Recommended Answers

All 4 Replies

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;

    }

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.