Liondancer
Liondancer

Reputation: 16479

Convert SRE_Match object to string

The output of my re.search returns <_sre.SRE_Match object at 0x10d6ed4e0> I was wondering how could I convert this to a string? or a more readable form?

Upvotes: 30

Views: 39782

Answers (2)

JOM
JOM

Reputation: 8207

If you want to see all groups in order:

result = re.search(your_stuff_here)
if result:
    print result.groups()

Upvotes: 6

sshashank124
sshashank124

Reputation: 32197

You should do it as:

result = re.search(your_stuff_here)
if result:
    print result.group(0)

Upvotes: 35

Related Questions