mid

Returns a substring of a specified string starting at the specified character and including the specified number of characters. Counting starts from one (1) (not zero (0)).

Always counts in the natural direction based on the selected advertiser’s locale. For example, if the advertiser’s language is English, this function counts from right to left.

Note: This function is only available in Templates and can’t be used in Reporting.

Syntax

mid(string, start, length)

Parameters

string can be any of the following:

  • Static text, such as "GDN".
  • A Search Ads 360 variable that uses a text format, such as Keyword, Campaign, and so on.
  • An expression or formula column that returns a text value.

start and length can be any of the following:

  • A positive constant, such as 5.
  • A Search Ads 360 variable that is a positive number.
  • An expression or formula column that returns a positive number.

Examples

  • [mid("Hello World!", 4, 8)] returns "lo Wo".

  • [mid("Hello World!", 5, 0)] returns "" (empty string).

  • [mid("Hello World!", 0, 12)] is an error. Counting begins with one (1), not zero (0).
  • [mid("every dog has its day", 1, -1)]is an error. Negative numbers are not valid.

Related links

Was this helpful?

How can we improve it?

Need more help?

Try these next steps:

true
Search
Clear search
Close search
Google apps
Main menu
4127388850848560932
true
Search Help Center
true
true
true
true
true
5055977
false
false