i have a string like this
var url="http://localhost/elephanti2/chaink/stores/stores_ajax_page/5/b.BusinessName/asc/1/11"
i want to get the string after the 7 th slash(/)
here it would be 5/b.BusinessName/asc/1/11
You don't need jquery for this, just pure JS.
var url= "http://localhost/elephanti2/chaink/stores/stores_ajax_page/5/b.BusinessName/asc/1/11"
re = /^([^\/]*\/){7}(.+)/
result = url.match(re)[2]
Regular expressions in javascript: http://www.regular-expressions.info/javascript.html
Rather than counting slashes, you should probably look for the part of the path right after a marker such as this:
var url="http://localhost/elephanti2/chaink/stores/stores_ajax_page/5/b.BusinessName/asc/1/11";
var endPath = url.replace(/^.*\/stores_ajax_page\//, "");
This is a little less brittle if the front part of the path ever gets changed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.