in perl you can do
if (/(.*)__(.*)/) {
print "ans" . $1 . ' ' . $2 . "\n";
}
in python, can you do the same? It seems like you can only do
m = re.match(r"(.*)__(.*),data)
if m:
print("ans {} {}".format(m[1],m[2])
Or is there better way to do this in more pythonic way?
Anyway, if this is the way to go, then it's gonna really suck if you have lot of big if and elif to test against many different possible patterns. I am really hoping someone who is more familiar w/ python can enlighten me
in perl
if (/(.*)__(.*)/){
#do another
} elsif ( /(.*)XXX___(.*)/) {
#do one thing
}
......
Imagine I have many test cases. In python, how would I do that?