user20184534
user20184534

Reputation: 41

Is it possible to change a word using regexp_replace() function?

Is it possible to change the State_Name to California using regexp_replace()?

select  REGEXP_replace("Name,Door_No,Street_Name,Area_Name,State_Name,12345", r"","California") AS example

Upvotes: 1

Views: 44

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172993

One of the many options -

#standardSQL
SELECT REGEXP_REPLACE(
  "Name,Door_No,Street_Name,Area_Name,State_Name,12345", 
  r"([^,]*,)([^,]*,)([^,]*,)([^,]*,)([^,]*)(,[^,]*)", 
  r"\1\2\3\4California\6"
) AS example

returns

Row example  
1   Name,Door_No,Street_Name,Area_Name,California,12345

Upvotes: 2

Related Questions