Home > Mobile >  Find word with Python "Regex"
Find word with Python "Regex"

Time:12-29

can you help please: i want to get the adress from that text using python:

 [RIPH] harambe protocol

First alert listed in this telegram group 637 seconds before anyone else.

Coin name:    harambe protocol
Address:         0x10964C2ffDEA1e99B5e26D102516d9b03368915f
Platform:        BSC
Time:               08:02:58 UTC

CodePudding user response:

try this:

import re

pattern = "Address:.*(0x.*)"

address = re.findall(pattern, your_text, re.MULTILINE)

print(address)

CodePudding user response:

Would you please try the following:

#!/usr/bin/python

import re

with open('textfile') as f:
    for line in f:
        m = re.search(r'Address:\s*(0[xX][0-9A-Fa-f] )', line)
        if (m):
            print(m.group(1))

Output:

0x10964C2ffDEA1e99B5e26D102516d9b03368915f
  • Related