How to change the words in the middle of a name into an asterisk?

Li * Ping
Murong * Cream

Mar.03,2021

the better way is to write a regular replacement, and what low forces is to judge the length and deal with it

.
var name = ''
nameArr = name.split('')
if (nameArr.length  > 2)
{
 nameArr[nameArr.length - 2] = '*'
}
return nameArr.join('')

"".replace(/^(.+).(.)$/, "$1*$2");
"".replace(/^(.+).(.)$/, "$1*$2");
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-1ea4b70-1cfa.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-1ea4b70-1cfa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?