I am using a function REGEXP_REPLACE
within SQL to generate a slug
value from name
column
UPDATE tag
SET slug = LOWER(REGEXP_REPLACE(
REGEXP_REPLACE('Team Building 2022', '^[^A-Za-z]+|[^A-Za-z]+$', '', 'g'),
'[^A-Za-z]+|(?<=[a-z])(?=[A-Z])', '-', 'g')
);
But I get: team-building
Result I want is: team-building-2022
Is there a way to add numbers in this function? Thanks
2
Answers
Resolved it with:
Well you did not actually specify what result you want. but from the actual question and the reply to @WiktorStribiżew it appears like you are wanting
team-building-2022
. If that is correct then you just need a simple replace() function (table 9.10) rather than a complicated regular expression. So just:If that is not the desired result then please post the exact result you want.