LTRIM in JS

Description

Unfortunately, this function is not available in JavaScript, but it can be implemented using regular expressions.

Sample Source Pattern

Implementation Example

function LTRIM(string){
    return string.replace(/^s+/,"");
}

Arguments

string: String expression to remove blank spaces.

Return Type

String.

Examples

CREATE OR REPLACE FUNCTION ltrim(str varchar)
  RETURNS string
  LANGUAGE JAVASCRIPT
AS
$$
  function LTRIM(string){
    return string.replace(/^s+/,"");
    }
   return LTRIM(S TR );
$$;

SELECT LTRIM('  FIRST TWO BLANK SPACES') AS LTRIM;

Last updated