-2

I have a field that contains a string (Column name of another table)

"call_records_2001.start_time"

I need to replace it with

"call_records_2002.start_time"

I wanted this should be working for similar patterns, call_records_2001.end_time, call_records_2001.duration, etc

So I tried to use Regular expression back-reference as below,

  `regexp_replace('call_records_2001.start_time','(.*)2001(.*)','\12002\2','gi')`

But here it is taken as \12002 instead of \1

So how can I separate \1 from 2002 ?

Also, I tried ${1} , <1> but these were not separating the data as I expected.

Thanks for your help.

1 Answers1

0

I found solution for this, we just need to use \\ instead of \ in back reference as below,

regexp_replace('call_records_2001.start_time','(.*)2001(.*)','\\12002\\2','gi')

It is working as I expected.

Dharman
  • 30,962
  • 25
  • 85
  • 135