Help write a rule?

A string of variable length, with 3 characters at the beginning and 3 characters at the end, and the rest of the content is replaced by a "" sign, and the number of "" is the same as the length of the content after removing the first and last 3 characters.

for example, let str = "123456789" becomes 123 * 789

the requirement is easy to realize. I"d like to ask, can it be realized with a regular sentence?

if the length is fixed

str.replace(/(.{3}).{3}(.{3})/, "$1***$2")

can be realized, mainly because the length is not fixed.

Mar.12,2021

'1234564526789'.replace(/(?<=\d{3})\d(?=\d{3})/g, '*')
'1234564526789'.replace(/(?<=.{3}).(?=.{3})/g, '*')

clipboard.png


replace accepts a function as a parameter. If the match is regular, then the first parameter of the function corresponds to $1 , the second corresponds to $2 , and so on. replace uses function as the parameter

let str = "123453333336789"
str.replace(/(^.{3})(.*)(.{3}$)/, "$1*$3")
//"123*789"
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e1f1-2c402.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e1f1-2c402.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?