cancel
Showing results for 
Search instead for 
Did you mean: 

RegEx to extract domain from website field

michael-wtds
Frequent Contributor

With the help of ChatGPT, I was able to get this RegEx formula to extract the company domain from website field.  The use case would be to update another field using the following formula -

RegExReplace(${Website}, "^(?:https?:\/\/)?(?:www\.)?([^\/]+)(\/.*)?$", "$1")

To extract the domain from the email, you can try this -
RegExReplace(${Email}, ".*@(.+)$", "$1")

And this may be useful to review contacts that don't have an email that matches the companies domain.

Good luck!

CC: @AnthonyValidity 

1 ACCEPTED SOLUTION

I checked both versions, found the 1st option removes additional page references (...domain.com/aboutus).

RegExReplace(${Website}, "^(?:https?:\/\/)?(?:www\.)?([^\/]+)(\/.*)?$", "$1")

This version appears to appears to be a wild card replacement similar to removing "http*//*www*"
 RegExReplace(${Website}, "^(?:https?:\/\/)?(?:www\.)?([^\/]+)", "$1")

@AnthonyValidity Thanks for the weekly call, and as I always pickup something useful.

View solution in original post

4 REPLIES 4

AnthonyValidity
Validity Team Member
Validity Team Member

This is great, @michael-wtds !  I Googled this one:

RegExMatch(${Website}, "[^(?:http:\/\/|www\.|https:\/\/)]([^\/]+)")

RegEx is awesome and there's usually more than one way to do the same thing!

Thanks for sharing,

 

Anthony Lardiere Jr
Senior Customer Success Manager

I checked both versions, found the 1st option removes additional page references (...domain.com/aboutus).

RegExReplace(${Website}, "^(?:https?:\/\/)?(?:www\.)?([^\/]+)(\/.*)?$", "$1")

This version appears to appears to be a wild card replacement similar to removing "http*//*www*"
 RegExReplace(${Website}, "^(?:https?:\/\/)?(?:www\.)?([^\/]+)", "$1")

@AnthonyValidity Thanks for the weekly call, and as I always pickup something useful.

AnthonyValidity
Validity Team Member
Validity Team Member

Hey @michael-wtds ,

Thanks for testing and sharing! I'll send over the one you provided to Petya.

It is seriously my pleasure - you all add so much to the calls and really make it a lot of fun for me and the team.  We appreciate your participation here and on Office Hours.

Hope you have a great rest of the week!

Anthony Lardiere Jr
Senior Customer Success Manager

michael-wtds
Frequent Contributor

When I tried matching existing accounts by website using the domain comparison, I didn't get any matching results.  But when I used the following RegEx matching type, it found all similar accounts -

^(?:https?:\/\/)?(?:www\.)?([^\/]+)(\/.*)?$

michaelwtds_0-1713965223932.png