2

I have a list of domains, hosts, and URLs. I would like to use either Notepad++'s extended or regex search to go through my list and give me just the domain. My list looks like:

fonts.googleapis.com 
fonts.gstatic.com 
http://s3.amazonaws.com/
*.adnxs.com
*.On24.com
ssl.gstatic.com
http://www.pinterest.com

What I'd like to end up with is a list of just the domain names such as:

googleapis.com
gstatic.com

Could someone provide a regex that would allow me to take a URL/FQDN and end up with just the domain?

KoreanGuy
  • 37
  • 1
  • 6

3 Answers3

1
.*\.(?=[^.]*\.[^.]*$)

You can use this.Replace by empty string.See demo.

https://www.regex101.com/r/rC2mH4/6

P.S This will fail in case of domains like something.com.au .They will have to handled separately.

vks
  • 67,027
  • 10
  • 91
  • 124
1

Try with the following regex in replace dialog of notepad++ (uncheck ". matches newline").
Find: ^[^.]+\.([^.]+\.[^./\r\n ]+)[ /]*$
Replace with: \1

"Replace All" should produce the list (tested with Npp version 7.6.6):

googleapis.com
gstatic.com
amazonaws.com
adnxs.com
On24.com
gstatic.com
pinterest.com
Robert K.
  • 11
  • 2
0

In notepad++ use replace feature and use regex like this for find pattern:

^[^.]*\.

Replace by empty string.

Zlopez
  • 660
  • 1
  • 5
  • 11