PostgreSQL BTRIM() function
BTRIM() function
The PostgreSQL btrim function is used to remove the longest string specified in the argument from the start and end of the given string. If no string for removing default space will be removed from leading and trailing side from the string.
Syntax:
btrim(<string>[ , <text_trim>])
PostgreSQL Version: 9.3
Pictorial Presentation of PostgreSQL BTRIM() function
Example - 1: PostgreSQL BTRIM() function:
In the example below, the btrim searches the letters 't' or 'e' or 's' or 't' from the left or right most position of the given string and removes those letters which match consecutively and displays the result 'w3resourc'.
Example:
Code:
SELECT btrim('settw3resourcesttes', 'test');
Sample Output:
btrim ----------- w3resourc (1 row)
Example - 2: PostgreSQL BTRIM() function:
In the example below, the btrim searches the letters white space ( ' ' ) in the given string and removes all white spaces from both sides of the given string.
Example:
Code:
SELECT btrim(' w3resource.com ');
Sample Output:
btrim ---------------- w3resource.com (1 row)
Example - 3: PostgreSQL BTRIM() function:
In the example below, no trimming text have been defined, so this statement by default will remove all white spaces from both sides of the given string.
Example:
Code:
SELECT btrim(' w3resource.com ');
Sample Output:
btrim ---------------- w3resource.com (1 row)
Previous: ASCII function
Next: CHR function
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework