Skip to main content
Version: 24.3.x

Categories: String

SIMILAR_TO

Tests whether the entire expression matches a pattern.

Syntax

expression SIMILAR TO pattern → boolean

  • expression: The expression to compare.
  • pattern: The pattern that is compared to the expression.

Examples

SIMILAR_TO example
SELECT 'shortcakes' SIMILAR TO '%cake_'
-- True

expression SIMILAR TO pattern ESCAPE escape_character → boolean

  • expression: The expression to compare.
  • pattern: The pattern that is compared to the expression.
  • escape: Putting an escape_character before a wildcard in the pattern makes SIMILAR TO treat the wildcard as a regular character when it appears in the expression.

Examples

SIMILAR_TO example
SELECT '100%' SIMILAR TO '100!%' ESCAPE '!'
-- True

Usage Notes

Succeeds only if the pattern matches the entire expression.