We would greatly appreciate some help figuring out the following regex for PostgreSQL.
Our Slackbot stores a message as a string and encloses the users' unique ids in "<>" like this:
Just an fyi agent <@U2LqweSTW> was just added to the Maco campaign, keep an eye out for any rookie questions in <@U2rtyGSTW> help channel... <@U2yjkGSTW> <@U2byqGSTW> :taco:
We'd like to extract that message and remove the user id in <>
to display the message without user ids. Here's what I'm using:
regexp_replace(r.message, '\<.*\>', '', 'gi')
Unfortunately, that returns this result:
Just an fyi agent :taco:
It's removing any characters after the first user id but keeping :taco:
.
I'm guessing it's because the user ids aren't grouped together, but my newb PostgreSQL skills have me dumbfounded as to why. Any explanations/solutions would be greatly appreciated.
In case another example is needed, the above regexp works correctly on this:
I will give our team a taco for that and as always <@U2124FSLS> we appreciate you always being there for us :taco: :taco:
It returns:
I will give our team a taco for that and as always we appreciate you always being there for us :taco: :taco: