954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

regular expressions

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?

saskvach
Newbie Poster
4 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

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?

saskvach
Newbie Poster
4 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

I agree with you.

Fuse
Light Poster
46 posts since Jun 2008
Reputation Points: 27
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You