How to reference to a group using a regex in MySQL? I tried:
REGEXP '^(.)1$'
but it does not work. How to do this?
(Old question, but top search result)
For MySQL 8:
SELECT REGEXP_REPLACE('stackoverflow','(.{5})(.*)','$2$1'); -- "overflowstack"
You can create capture groups with (), and you can refer to them using $1, $2, etc.
()
$1
$2
1.4m articles
1.4m replys
5 comments
57.0k users