I have a redshift database that I need to query, and need to group similar strings together. I'm using regexp_replace() to do this, but can't work out how to get it grouping strings that have integers in the middle. For example:
dataset:
string
'aaa/123/bbb'
'aaa/456/bbb'
'ccc/123/ddd'
I need to group this so that we'd get
string count(*)
aaa/id/bbb 2
ccc/id/ddd 1
So I have tried using
regexp_replace(endpoint, '/[0-9]+$/', '/id/')
But it doesn't work, I'm assuming because there is no wildcard or something? But I can't work out how to fix this.
Thanks in advance