Home > Enterprise >  how to get .com domains from a text file python regex?
how to get .com domains from a text file python regex?

Time:08-16

Test file: https://www.snapnames.com/file_dl.sn?file=snpdeletingsoon5list.zip

A Sample of inside text file

Domain Name                                                         Current Bid     Join By Date (ET)   Join By Date (PT)   Bidders     Seller          TLD         Length  Words                                                                               Word Count  Categories                                                                                                          Hyphens     Numbers     Auction Type
    00e.us                                                                       79      08/16/2022 20:00    08/16/2022 17:00               Drop            .us              3                                                                                                                                                                                                                      No          Yes         Available Soon
    01nz-mtzh.biz                                                                79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             9                                                                                                                                                                                                                      Yes         Yes         Available Soon
    0amc-wpev.biz                                                                79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             9                                                                                                                                                                                                                      Yes         Yes         Available Soon
    0dg.us                                                                       79      08/16/2022 20:00    08/16/2022 17:00               Drop            .us              3                                                                                                                                                                                                                      No          Yes         Available Soon
    0mkfig2od1941hqx7u.biz                                                       79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz            18                                                                                                                                                                                                                      No          Yes         Available Soon
    0wd.us                                                                       79      08/16/2022 20:00    08/16/2022 17:00               Drop            .us              3                                                                                                                                                                                                                      No          Yes         Available Soon
    10c1g71a4y0myweket.biz                                                       79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz            18                                                                                                                                                                                                                      No          Yes         Available Soon
    11534.biz                                                                    79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             5                                                                                                                                                                                                                      No          Yes         Available Soon
    12zodiak-news.biz                                                            79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz            13                                                                                                                                                                                                                      Yes         Yes         Available Soon
    15432.biz                                                                    79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             5                                                                                                                                                                                                                      No          Yes         Available Soon
    17999.biz                                                                    79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             5                                                                                                                                                                                                                      No          Yes         Available Soon
    18617.biz                                                                    79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             5                                                                                                                                                                                                                      No          Yes         Available Soon
    1932.us                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .us              4                                                                                                                                                                                                                      No          Yes         Available Soon
    1ae.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1af.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1aj.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1al.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1am.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1an.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1ao.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1ap.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1aq.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1ar.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1as.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1at.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1aw.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    usa-master.com                                                               79      08/16/2022 20:00    08/16/2022 17:00               Drop            .com             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1ba.biz                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .biz             3                                                                                                                                                                                                                      No          Yes         Available Soon
    usa.com                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .com             3                                                                                                                                                                                                                      No          Yes         Available Soon
    1bg.com                                                                      79      08/16/2022 20:00    08/16/2022 17:00               Drop            .com             3

     

I want to collect xxx.com domains only (without Hyphens or Numbers) like:

usa.com
asd.com
abc.com

Even If there is a Hyphens or Numbers in .com domains, that is unacceptable usa-master.com not unacceptable ca18.com not unacceptable

Which regex do i need? Thanks

CodePudding user response:

you can try this regex pattern :

"\w{3}\.com"

this is the full code you can use:

import re
pattern = r"\w{3}\.com"
re.findall(pattern, your_string)

CodePudding user response:

If I understand your question correctly you need the following :

pattern = r"^[^-\d] .com$"

If other characters are to be banned, add them inside [] after the second ^ character.

  • Related