regular expression - parent domain only

Looking for a regex that will match the parent domain only.
in examples like the following   =  =   =  =

This is the output of a cmdlet that won't produce any http:// prefix, nor any trailing pages - just the domain info, but I only want to extract the parent. Thanks!
LVL 67
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


pls try


Open in new window

EDIT and for or


Open in new window

sirbountyAuthor Commented:
I don't know enough regex to know why it's not working, but it doesn't seem to be picking out that information.
I've tried both in powershell and
Don't understand it works in

how do you use it?
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

sirbountyAuthor Commented:
I have these examples in regextester:

Should it highlight just one, or any matches?
I'll be pulling these from an array, if that matters?
sirbountyAuthor Commented:
If I take off the trailing $, it matches the def.ghi portion of this, but I would need from it...doesn't match anything with the $ left on.
sirbountyAuthor Commented:
Weird - same regex and test as your screen shot, but it fails on mine with the exact same data?

Is there a space after org?
When you're trying to match TLD's and also catching country TLD's its a bit of a pain. I would use an exclusion match on the delimiter..

I've included all of the valid country TLD's (as per the Wikipedia article on the subject) and one with just the .uk TLD. I wouldn't use \w for the TLD as I don't think you'll find a TLD with a number in it.

UK TLD only

Open in new window

All country TLD's

Open in new window

If you are really keen you can probably go ahead and make sure that no rules are being broken like domain names starting, ending or containing multiple hyphens in sequence. Examples.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sirbountyAuthor Commented:
Thanks to you both
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.