Page tree


Contents:

NOTE:  Designer Cloud Educational is a free product with limitations on its features. Some features in the documentation do not apply to this product edition. See Product Limitations.

   

Finds the suffix value after the domain from a valid URL. Input values must be of URL or String type.

This function is part of a set of functions for processing URL data.

Wrangle vs. SQL: This function is part of Wrangle, a proprietary data transformation language. Wrangle is not SQL. For more information, see Wrangle Language.

 

Basic Usage

URL literal examples:

suffix(&apos;<span class="nolink">http://www.example.com</span>&apos;)

Output: Returns the value com

suffix(&apos;<span class="nolink">http://www.exampl.e.com</span>&apos;)

Output: Returns the value com

Column reference example:

suffix(myURLs)

Output: Returns the suffix values extracted from the myURLs column. 

Syntax and Arguments

suffix(column_url)


ArgumentRequired?Data TypeDescription
column_urlYstringName of column or String or URL literal containing the suffix value to extract

For more information on syntax standards, see Language Documentation Syntax Notes.

column_url

Name of the column or URL or String literal whose values are used to extract the suffix value.

  • Missing input values generate missing results.
  • Multiple columns and wildcards are not supported.

Usage Notes:

 

Required?Data TypeExample Value
YesString literal or column reference (URL)http://www.example.com

Examples


Tip: For additional examples, see Common Tasks.

Example - Domain, Subdomain, Host, and Suffix functions

This examples illustrates how you can extract component parts of a URL using specialized functions for the URL data type.

Functions:

ItemDescription
DOMAIN Function Finds the value for the domain from a valid URL. Input values must be of URL or String type.
SUBDOMAIN Function Finds the value a subdomain value from a valid URL. Input values must be of URL or String type.
HOST Function Finds the host value from a valid URL. Input values must be of URL or String type and can be literals or column references.
SUFFIX Function Finds the suffix value after the domain from a valid URL. Input values must be of URL or String type.
URLPARAMS Function Extracts the query parameters of a URL into an Object. The Object keys are the parameter's names, and its values are the parameter's values. Input values must be of URL or String type.
FILTEROBJECT Function Filters the keys and values from an Object data type column based on a specified key value.

Source:

Your dataset includes the following values for URLs:

URL
www.example.com
example.com/support
http://www.example.com/products/
http://1.2.3.4
https://www.example.com/free-download
https://www.example.com/about-us/careers
www.app.example.com
www.some.app.example.com
some.app.example.com
some.example.com
example.com
http://www.example.com?q1=broken%20record
http://www.example.com?query=khakis&app=pants
http://www.example.com?q1=broken%20record&q2=broken%20tape&q3=broken%20wrist

Transformation:

When the above data is imported into the application, the column is recognized as a URL. All values are registered as valid, even the numeric address.

To extract the domain and subdomain values:

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula DOMAIN(URL)
Parameter: New column name 'domain_URL'

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula SUBDOMAIN(URL)
Parameter: New column name 'subdomain_URL'

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula HOST(URL)
Parameter: New column name 'host_URL'

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula SUFFIX(URL)
Parameter: New column name 'suffix_URL'

You can use the Pattern  in the following transformation to extract protocol identifiers, if present, into a new column:

Transformation Name Extract text or pattern
Parameter: Column to extract from URL
Parameter: Option Custom text or pattern
Parameter: Text to extract `{start}%*://`

To clean this up, you might want to rename the column to protocol_URL.

To extract the path values, you can use the following regular expression:

NOTE: Regular expressions are considered a developer-level method for pattern matching. Please use them with caution. See Text Matching.

Transformation Name Extract text or pattern
Parameter: Column to extract from URL
Parameter: Option Custom text or pattern
Parameter: Text to extract /[^*:\/\/]\/.*$/

The above transformation grabs a little too much of the URL. If you rename the column to path_URL, you can use the following regular expression to clean it up:

Transformation Name Extract text or pattern
Parameter: Column to extract from URL
Parameter: Option Custom text or pattern
Parameter: Text to extract /[!^\/].*$/


Delete the path_URL column and rename the path_URL1 column to the deleted one. Then:

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula URLPARAMS(URL)
Parameter: New column name 'urlParams'

If you wanted to just see the values for the q1 parameter, you could add the following:

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula FILTEROBJECT(urlParams,'q1')
Parameter: New column name 'urlParam_q1'

Results:

For display purposes, the results table has been broken down into separate sets of columns.

Column set 1:

URLhost_URLpath_URL
www.example.comwww.example.com 
example.com/supportexample.com/support
http://www.example.com/products/www.example.com/products/
http://1.2.3.41.2.3.4 
https://www.example.com/free-downloadwww.example.com/free-download
https://www.example.com/about-us/careerswww.example.com/about-us/careers
www.app.example.comwww.app.example.com 
www.some.app.example.comwww.some.app.example.com 
some.app.example.comsome.app.example.com 
some.example.comsome.example.com 
example.comexample.com 
http://www.example.com?q1=broken%20recordwww.example.com 
http://www.example.com?query=khakis&app=pantswww.example.com 
http://www.example.com?q1=broken%20record&q2=broken%20tape&q3=broken%20wristwww.example.com 

Column set 2:

URLprotocol_URLsubdomain_URLdomain_URLsuffix_URL
www.example.com wwwexamplecom
example.com/support  examplecom
http://www.example.com/products/http://wwwexamplecom
http://1.2.3.4http://   
https://www.example.com/free-downloadhttps://wwwexamplecom
https://www.example.com/about-us/careershttps://wwwexamplecom
www.app.example.com www.appexamplecom
www.some.app.example.com www.some.appexamplecom
some.app.example.com some.appexamplecom
some.example.com someexamplecom
example.com  examplecom
http://www.example.com?q1=broken%20recordhttp://wwwexamplecom
http://www.example.com?query=khakis&app=pantshttp://wwwexamplecom
http://www.example.com?q1=broken%20record&q2=broken%20tape&q3=broken%20wristhttp://wwwexamplecom

Column set 3:

URLurlParamsurlParam_q1
www.example.com  
example.com/support  
http://www.example.com/products/  
http://1.2.3.4  
https://www.example.com/free-download  
https://www.example.com/about-us/careers  
www.app.example.com  
www.some.app.example.com  
some.app.example.com  
some.example.com  
example.com  
http://www.example.com?q1=broken%20record{"q1":"broken record"}{"q1":"broken record"}
http://www.example.com?query=khakis&app=pants{"query":"khakis","app":"pants"} 
http://www.example.com?q1=broken%20record&q2=broken%20tape&q3=broken%20wrist{"q1":"broken record", "q2":"broken tape",
"q3":"broken wrist"}
{"q1":"broken record"}

See Also for EXAMPLE - Domain Functions:

 

This page has no comments.