-
1. Re: How to truncate a long URL to display domain name only?
Mark Holtz Feb 12, 2013 1:55 PM (in response to Leigh Fonseca)1 of 1 people found this helpfulHi Leigh,
I believe you could use LEFT([URL Field],FIND([URL Field],'.com/')+5) (you could use '.com'+4 instead to drop the slash) to get to this.
FIND returns the start position in a string of a substring. So if the substring of '.com/' occurs in the URL, then you'd want the LEFT of the URL value until the start of that string plus 5 positions.I'm not positive what FIND() returns when the substring does not exist in the string searched, but if your URLs do not always have '.com/' substring, you can set up a CASE statement to handle any .net/ or .org/ URLs..
-
2. Re: How to truncate a long URL to display domain name only?
Mark Holtz Feb 12, 2013 1:59 PM (in response to Mark Holtz)Another thought--you can also specify a start position in the FIND function. So if you know you always want to skip the first "http://www" (1st 10 characters), you could also calculate:
LEFT([URL Field],FIND([URL Field],'/',10)+10)The 10 inside the FIND tells the function not to return the position of a '/' until after the first 10 characters. So, the +10 forces the LEFT to always bring back the first 10 characters, and then to keep going until another '/'
-
3. Re: How to truncate a long URL to display domain name only?
Cristian Vasile Feb 12, 2013 2:44 PM (in response to Leigh Fonseca)Leigh,
you should use the following approach:
1. find first // in string (i mean at which position is )
2. starting with pos + 2 find first /
3. extrcat the string between two positions
regards,
Cristian.
-
4. Re: How to truncate a long URL to display domain name only?
Leigh Fonseca Feb 12, 2013 5:07 PM (in response to Mark Holtz)Hi Mark,
Thanks for the tips. I was able to useLEFT([URL],FIND([URL],'/',8))
to get
I'd like to trim the trailing '/' and wasn't able to do so with the code suggestions here. I think since it doesn't affect the page loading as a link it should be fine and am VERY thankful for the help getting the rest of the URL trimmed.
Thanks!
Leigh -
5. Re: How to truncate a long URL to display domain name only?
Mark Holtz Feb 13, 2013 5:15 AM (in response to Leigh Fonseca)1 of 1 people found this helpfulHi Leigh,
Glad that helps.
If you'd prefer to trim off the last '/', you should be able to just modify the "length" argument of the left function by subtracting 1: LEFT([URL],FIND([URL],'/',8)-1).
-
6. Re: How to truncate a long URL to display domain name only?
Leigh Fonseca Feb 19, 2013 2:21 PM (in response to Mark Holtz)Thanks again, Mark. I also decided to trim off the http:// so my ending code was:
mid(LEFT([URL],FIND([URL],'/',8)-1), 8)
Cheers,
Leigh