New topic Closed topic
avatar image
1
Extract hostname from URL
By Created , last editted

Hi all,

From my endpoint, I get URLs like 

https://www.test.com/hello/hi.php
http://portal.myweb.com/entrypoint/index.php
https://mynet.company.nl:8080/cool/
Etc.

I would like to extract just the hostname (and if applicable) the port number, thus:

test.com
portal.myweb.com
mynet.company.nl:8080

In the BettyBlocks reference is only see the regex_replace that might be able to do this job. However, it seems to be difficult to extract the 'mess' and replace that with "". E.g. the regex to extract the URL is  \/\/([^\/,\s]+\.[^\/,\s]+?)(?=\/|,|\s|$|\?|#) = however, I cannot replace that since I will than wipe the URL. I need a BettyBlocks expression where I am able to define a regex and the expression gives me the match as result.


I know there are JS libraries/functions to do this. For security reasons I need to do this job serverside....


Would be great if we can get this working!

Kind regards, Arno


Hi all,

From my endpoint, I get URLs like 

https://www.test.com/hello/hi.php
http://portal.myweb.com/entrypoint/index.php
https://mynet.company.nl:8080/cool/
Etc.

I would like to extract just the hostname (and if applicable) the port number, thus:

test.com
portal.myweb.com
mynet.company.nl:8080

In the BettyBlocks reference is only see the regex_replace that might be able to do this job. However, it seems to be difficult to extract the 'mess' and replace that with "". E.g. the regex to extract the URL is  \/\/([^\/,\s]+\.[^\/,\s]+?)(?=\/|,|\s|$|\?|#) = however, I cannot replace that since I will than wipe the URL. I need a BettyBlocks expression where I am able to define a regex and the expression gives me the match as result.


I know there are JS libraries/functions to do this. For security reasons I need to do this job serverside....


Would be great if we can get this working!

Kind regards, Arno

Answers
Sort by:

This topic is closed.