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

Edited by rpaterick
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...