'\S' means some character other than a space or tab, so the expression above does not match when the apostrophe-s is followed by a space or tab (or end-of-string).
SELECT REGEXP_REPLACE ( address_1 , '''s(\S)' , '''S\1' ) AS new_adddress_1 FROM my_table ;
user11089573 wrote:In the 3nd argument, '\1' is a Backreference . It means the part of the expression in the 2nd argument inside the 1st left '(' and its matching right ')'. In this case, that means the non-spacing character (space, tab, newline) that matched \S
Thank you Frank. I just tested it out and it is working! But I'd like to fully understand the expression you wrote.
What is this 's(\S)' and '''S\1' doing?
SELECT REGEXP_REPLACE ( address_1 , '''s' || -- apostrophe and lower-case s '(\S)' -- \1, which is any non whitespace character , '''S' || -- apostrophe and capital-S '\1' -- whatever \1 was ) AS new_adddress_1