trim_wspace

NAME

trim_wspace(): Trim white space characters on both sides of text.

TYPE

Function

DESCRIPTION

As opposed to the standard TRIM() function, which only trims strict space characters (' '), trim_wspace() also trims new line, tab and backspace characters.

SYNOPSIS

trim_wspace(txt TEXT CHARSET utf8)
  RETURNS TEXT CHARSET utf8 

Input:

  • txt: text to trim In case of NULL, the function returns NULL.

EXAMPLES

Trim text (spaces between literals are unaffected):

SELECT trim_wspace('\n a b c \n   ') AS res;
+-------+
| res   |
+-------+
| a b c |
+-------+

Similar to the above, quoted for clarity:

SELECT CONCAT('"', trim_wspace('\n the quick brown fox \n   '), '"') AS res;
+-----------------------+
| res                   |
+-----------------------+
| "the quick brown fox" |
+-----------------------+

ENVIRONMENT

MySQL 5.1 or newer

SEE ALSO

replace_all()

AUTHOR

Shlomi Noach
 
common_schema documentation