简体   繁体   中英

Find word with Python "Regex"

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

try this:

import re

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

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

print(address)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM