Home > Mobile >  How to remove leading space in this string in BigQuery?
How to remove leading space in this string in BigQuery?

Time:11-04

I have some values in my data that have leading spaces in the string character. Looks like when the data was inputted someone left a space by mistake. How can I remove that leading space? I would assume it would be a regex solution.

enter image description here

CodePudding user response:

You can use Bigquery TRIM function to remove spaces on a STRING value, example :

SELECT
  '  Original String_',
TRIM('  Original String_') AS trimmed,
LTRIM('  Original String_') AS left_trim,
RTRIM('  Original String_', "_") AS right_trim
  • TRIM removes left and right spaces
  • LTRIM removes only left spaces
  • RTRIM removes only right spaces
  • Related