Regular expression - javascript regular expression to list strings in links
世界只因有你2017-06-26 10:54:30
0
3
957
http://www.xxx.com/one/two/three/four
Find the characters after each / in the link and put them into an array, such as: ['one','two','three','four'] There is no limit on link length. How to write regular expression?
is the current page url:
window.location.pathname.substr(1).split('/')
Not the current page url:
url.replace(/http(s){0,1}://[^/]+//, '').split('/')
window.location.pathname.split('/')
The idea upstairs is good, remove the host in front, and use / to divide the rest, which is simpler
------Here are the answers
This requires the use of assertions