Get the locale in a subdomain structure

Important: You must include the protocol (http:// or https://)

Video Example


  • url: The url where to extract the locale

  • defaultValue: The default value used for the main lang version without specifying a locale subdomain

  • defaultLocale: The default locale to return when no locale is found

Expected Output

  • String: The string with the locale

Text example

getLocaleBySubdomain("", "www", "ES")
// "ES"

getLocaleBySubdomain("", "www", "ES")
// "EN"

Use cases

  • Extract URL patterns in Sheets

  • Extract subdomains in Spreadsheet

Last updated