Remove www. & .com

Hi, I am trying to remove the remove any text before the first “.” and after the second “.” so that www.websitename.com becomes websitename

Could someone help me as I couldn’t get it to work with a template function

image

Try the following in a JavaScript column:

return p1.split('.')[1];

Use the URL as a replacement for p1

That is great. the only issue is where the www. does not exist in the website. I was thinking of using an if-then-else to check for the www. existing and then another javascript colum that removes the characters after the first “.”

See the item second from bottom
image

or do you have a better suggestion and if you think this would be best then could you help me with the javascript for this removal.

Thanks

return p1.match(/www/) ? p1.split('.')[1] : p1.split('.')[0];

But beware that if you’re likely to have other variations, the above might break in different ways.

understood but thank you for helping me for now.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.