Skip to main content

Categories: String

SUBSTR

Returns the portion of the string from the specified base expression starting at the specified characters. This function supports regular expressions.

Syntax

SUBSTR(string_expression varchar, offset int64) → varchar

  • string_expression: Base expression to extract substring from.
  • offset: The offset from which the substring starts.

Examples

SUBSTR example
SELECT SUBSTR('dremio user 1 2 3', 12)
-- 1 2 3

SUBSTR(string_expression varchar, offset int64, length int64) → varchar

  • string_expression: Base expression to extract substring from.
  • offset: The offset from which the substring starts.
  • length (optional): The length limit of the substring.

Examples

SUBSTR example
SELECT SUBSTR('base expression', 6, 4)
-- expr

SUBSTR(string_expression varchar, pattern varchar) → varchar

  • string_expression: Base expression to extract substring from.
  • pattern: The offset from which the substring starts.

Examples

SUBSTR example
SELECT SUBSTR('dremio user 123', '[0-9]+')
-- 123