這裏再來javascript noob。Javascript字符串修剪:網址和文件路徑
我想做什麼。 1:
// I will have many URLs as input
// I want to check if URL NOT end with slash
// if not then trim string after slash
var given_URL = "http://www.test.com/test"
var trimmed_URL = "http://www.test.com/"
我想做什麼。 2:
// I will have many file paths
// I would like to check if the path starts with unwanted dot OR slash
// If so, I would like to trim it
var given_path_1 = "./folder/filename.xxx"
var given_path_2 = "/folder/filename.xxx"
var given_path_3 = ".folder/filename.xxx"
var trimmed_path = "folder/filename.xxx"
我想知道如何實現這些。 在此先感謝
你**域後尋找串** –
我試圖消除完成打字量最少的工作領域 – RNA