this was the question on my exam the other day
Which strings does regular expression r"^([^aeiou]\w)+\1$" recognize? (3 answers)
"o_o-o_"
"baraba"
"ananas"
"anasan"
"-O->-O"
"izgriz"

im not into re at all :D, I tried to compile that expression and check for every string.. funny thing was that none was recognized..
so, my mistake or was there mistake in question?

ok, i checked it like this

from re import *
a=compile(r"^([^aeiou]\w)+\1$")
list=["o_o-o_", "baraba", "ananas", "anasan", "-O->-O", "izgriz"]
for string in list: 
     x=a.match(string)
     if x:
         print "ok"
     else:
        print "no"

is that code okay?

I agree with you.

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.