This content has been marked as final. Show 4 replies
Here's one way:
'\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 ;
Edited by: Frank Kulash on Feb 12, 2013 4:40 PM
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?
It might be easier to understand with some in-line comments:
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