TRIM

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

Sintassi

TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)

Spiegazione

Restituisce la stringa str dopo aver rimosso tutti i prefissi o i suffissi remstr. Se non viene specificato BOTH, né LEADING, né TRAILING, il default è BOTH. remstr è opzionale; se non è specificato, vengono rimossi gli spazi.

Esempi

MariaDB [(none)]> SELECT TRIM('  bar   ')\G
*************************** 1. row ***************************
TRIM('  bar   '): bar
1 row in set (0.00 sec)

MariaDB [(none)]> SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx')\G
*************************** 1. row ***************************
TRIM(LEADING 'x' FROM 'xxxbarxxx'): barxxx
1 row in set (0.00 sec)

MariaDB [(none)]> SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx')\G
*************************** 1. row ***************************
TRIM(BOTH 'x' FROM 'xxxbarxxx'): bar
1 row in set (0.00 sec)

MariaDB [(none)]> SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz')\G
*************************** 1. row ***************************
TRIM(TRAILING 'xyz' FROM 'barxxyz'): barx
1 row in set (0.00 sec)

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.