I use Postgresql and need to replace numbers to asterisk at database layer. Howerver I’m new to learn regex and seems to be hard to do this with my current knowledge.
I will have in my database 16 numbers varchar and I need to replace middle numbers with asterisk.
Example.
123467812345678 -> 12**********5678
Could someone tell me how regex for this should look like in postgresql ?
Thanks in advance
>Solution :
Thanks to @Wiktor Stribiżew:
SELECT regexp_replace('123467812345678', '(?<=..).(?=....)', '*','g');