In DB2, the next query works fine:
select REGEXP_REPLACE( 'René de la Ömer-Arie IJsbrand IJsse'
,'(^[A-Z])|([IJ])|(?<= ).','') FROM "SYSIBM".SYSDUMMY1
Result: ené e a mer-Arie sbrand sse
However, I would like to achieve the opposite result:
RdlÖIJIJ
If I try the regexp_substr equivalent, it doesn't give me the desired outcome:
select REGEXP_SUBSTR( 'René de la Ömer-Arie IJsbrand IJsse'
,'(^[A-Z])|([IJ])|(?<= ).') FROM "SYSIBM".SYSDUMMY1
Result: R
Is there a way to achieve the result "RdlÖIJIJ" with (or without) regexp_substr?
CodePudding user response:
You could match a char other than I
or J
while asserting a non whitespace char to the left, and replace with an empty string.
(?<=\S)[^IJ]