【发布时间】:2017-03-16 07:01:02
【问题描述】:
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"
我想知道如何实现这些。 提前致谢
【问题讨论】:
-
您是否在寻找 domain 之后的字符串
-
我正在尝试消除域后的字符串
标签: javascript string syntax trim