I have
'VA - HRD 1, VA - HRD 1, VA - NOVA 1, VA - NOVA 1'
and want to get
'VA - HRD 1, VA - NOVA 1'
I am trying
regexp_replace( 'VA - HRD 1, VA - HRD 1, VA - NOVA 1, VA - NOVA 1' ,'([^,]+)(,\1)+', '\1')
but it doesn't remove all duplicates, it produces: VA - HRD 1, VA - HRD 1, VA - NOVA 1
Please help...
Select replace(REGEXP_REPLACE('1234567890,2220006789,2220006789,477-000-6789','([^,]+)(,[ ]*\1)+'),',,',',')
As [columnName] From [tableName]
([^,]+)(,[ ]*\1)+
Try this.This works.See demo.
http://regex101.com/r/yG7zB9/8
The issue was VA - HRD 1, VA - HRD 1
^ ^
The space here.You were not taking this into account as the first match has no space behid it.So inlcde [ ]*
or \s*
to make it accept.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With