strings.ends_with

Compatível com:
strings.ends_with(value, suffix)

Descrição

A função usa duas strings (value, suffix). Retorna "true" se o sufixo não estiver vazio e estiver no final do valor.

Tipos de dados de parâmetros

STRING, STRING

Tipo de retorno

BOOL

Amostras de código

Os exemplos de código a seguir ilustram algumas das maneiras de usar a função strings.ends_with.

Exemplo: retorna "true"

Retorna "true" quando o sufixo é encontrado no final do valor.

strings.ends_with(target.hostname, "com") = true
Exemplo: retorna "false"

Retorna "false" quando o sufixo não está no fim do valor.

strings.ends_with(target.hostname, "com") = false
Exemplo: retorna "false" quando são idênticos

Retorna "false" quando o sufixo e o valor são idênticos.

target.hostname != "example.com"
strings.ends_with("str", "str") = true
Exemplo: retorna "false" quando o sufixo está vazio

Retorna "false" quando o sufixo é uma string vazia.

target.hostname != "example.com"
strings.ends_with("str", "") = false
Exemplo: retorna "false" quando o valor está vazio

Retorna "false" quando o valor é uma string vazia.

target.hostname != "example.com"
strings.ends_with("", "str") = false
Exemplo: retorna "false" quando o sufixo e o valor estão vazios

Retorna "false" quando o sufixo e o valor são strings vazias.

target.hostname != "example.com"
strings.ends_with("", "") = false