Skip to content

Latest commit

 

History

History
47 lines (36 loc) · 1.76 KB

mask_show_last_n.md

File metadata and controls

47 lines (36 loc) · 1.76 KB
description
Returns a masked version of a string with the last num_chars characters unmasked. By default, if you do not provide a value, the last four characters are shown.

MASK_SHOW_LAST_N

Syntax

MASK_SHOW_LAST_N(expression varchar, num_chars int, uc_mask varchar, lc_mask varchar, num_mask varchar) → varchar

  • expression: The string to mask.
  • num_chars: The number of characters to unmask.
  • uc_mask: Controls the mask character for upper case letters.
  • lc_mask: Controls the mask character for lower case letters.
  • num_mask: Controls the mask character for numbers.

Examples

{% code title="MASK_SHOW_LAST_N example" %}

SELECT MASK_SHOW_LAST_N('ab12-ABab-1234')
-- xxnn-XXxx-1324

{% endcode %}

{% code title="MASK_SHOW_LAST_N example containing optional value." %}

SELECT MASK_SHOW_LAST_N('ab12-ABab-1234', 2)
-- xxnn-XXxx-nn34

{% endcode %}

{% code title="MASK_SHOW_LAST_N example containing optional arguments." %}

SELECT MASK_SHOW_LAST_N('Aa12-ABab-1234', 4, 'U', 'u', '#')
-- Uu##-UUuu-1234

{% endcode %}

Usage Notes

By default, upper case letters are converted to X, lower case letters are converted to x, and numbers are converted to n. You can override the characters used in the mask by supplying optional arguments. The second argument controls the mask character for upper case letters, the third argument for lower case letters, and the fourth argument for numbers.

\