Deleted everything before the dot

Viewed 41

How can I use regex in notepad++ to make a query like this: I have a list with subdomains containing three words such as

web1.com

test.web2.com

www.test.web3.com

I want to filter so that only three words remain and something like this comes out:

web1.com

test.web2.com

test.web3.com

I was able to delete so that only the domain remains, but this is not what I want

^(?:.+\.)?([^.\r\n]+\.[^.\r\n]+)$
2 Answers

Another take at it using a positive lookahead to assert the 3 "words" to the right, allowing for non whitespace chars excluding a dot using [^\s.]

In the replacement use an empty string.

^\S+?\.(?=[^\s.]+\.[^\s.]+\.[^\s.]+$)

See a regex demo.

enter image description here

Related