How does a rule match a specific character in a string?

such as a string:

"/content/dam/sonystyle/products/color/silver/color_icon_grey_30x30.gif"

"/content/dam/sonystyle/products/color/"
silver
Mar.07,2021

function getKey() {
    const reg = /\/content\/dam\/sonystyle\/products\/color\/([^\/]+)\/.+/;
    const res = reg.exec('/content/dam/sonystyle/products/color/silver/color_icon_grey_30x30.gif');
    return res && res[1];
}

/ content/dam/sonystyle/products/color/ ([^\ /] *) [$| /]. $


var a = "/content/dam/sonystyle/products/color/silver/color_icon_grey_30x30.gif"
var reg = /\/content\/dam\/sonystyle\/products\/color\/([^\/]+)/;
var v = reg.exec(a)[1];
console.log(v);

personally feel that there is no need to use regularization

let str = '/content/dam/sonystyle/products/color/silver/color_icon_grey_30x30.gif'
let len = '/content/dam/sonystyle/products/color/'.length
str = str.slice(len) // str = 'silver/color_icon_grey_30x30.gif'
str = str.split('/') // str = ['silver', 'color_icon_grey_30x30.gif']
str = str[0] // str = 'silver'
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-1b3eab1-2c412.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-1b3eab1-2c412.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?