Jump to content

Trimming data


rpaterick

Recommended Posts

edit. I figured it out in different way. Still not sure how a TRIM function would work properly though?

 

Instead of:

http:/www.Ryans.MyPrePassBenefits.com

 

It would be:

www.Ryans.MyPrePassBenefits.com

Basically getting rid of the http:/

 

Here is the code I came-up with that worked.

var s = Field("Personalized URLs");
s = ReplaceSubstring(s, "http:/", "");
return s;

 

Thanks

Link to comment
Share on other sites

Assuming you want to eliminate everything before "www." I think it may be a better solution to use a regex to get rid of it. Especially considering most websites start with "http://" the code that you wrote would return a string starting with a "/".

 

The following code will replace all patterns starting with a series of letters ending with a ":" followed by one or more "/" to handle addresses that start with "http:/" , "http://", "https://", "ftp://", etc.

 

var s = "http://www.Ryans.MyPrePassBenefits.com";
return s.replace(/(\w+:\/+)/,"");

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...