Reputation: 2210
I have the following string
/products/id/edit'
i want to get the substring products
using javascript but i am not sure how to do it? Any pointers will be great. Thanks
Upvotes: 2
Views: 26
Reputation: 2633
String objects have a .split()
method:
'/products/id/edit'.split('/')
Which outputs a four member array; one for each string around the slashes:
["", "products", "id", "edit"]
Does that accomplish what you're hoping for?
Upvotes: 1