简体   繁体   中英

Trying to extract specific string in larger string

I have a set of raw data attached within a JSON file like the following, this is all one big string:

\nRegistrant Street: 2100 Example Drive\nRegistrant City: Example \nRegistrant State/Province: EX\nRegistrant Postal Code: 11001\nRegistrant Country: US\nRegistrant Phone: +1.8008008000\nRegistrant Phone Ext:\nRegistrant Email: example@example.com\nRegistrant Fax: \nRegistrant Fax Ext:

If I wanted to extract the registrant email from the above string, what would your solution to this be? I am currently appending anything with an "@" to a list, but this seems to be picking up a lot of stuff I do not want, and I cannot think of another way of doing this.

Any suggestions/modules I should look into?

Thanks, your input is very much appreciated.

You could use some regex here : https://docs.python.org/3/library/re.html

A regex for mail would be :

([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+

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